用数据说话,为什么要学Python(1)

Python 是不是越来越火了?

答案是肯定的。

那么为什么 Python 现在越来越火了?也许有人感觉 Python 火了是因为我们关注它,Python火是被炒起来的。还是让我们用数据说话吧!

下图是 Python 的百度搜索指数:

从 2007开始到现在,Python 的百度搜索指数翻了50 倍. 这是中国为主的数据。在2017年8月, 中国国内对Python的关注超过了Java.

下图是 Python 的google搜索指数:

从 2007开始到现在,Python的google搜索指数翻了5 倍.在全球的范围内,在2019年5月Python的关注搜索指数超过了Java. 

微信也推出了微信指数(在微信中搜索微信指数)。Python的关注微信指数远远高过了包括Java在内的其他语言。但历史数据太短,只能作为参考。

TIOBE和PYPL的5月编程语言排行榜:如果你只能学习一门语言,Python是最好的选择!

再看一下一个TIOBE Index编程语言排行榜

注:TIOBE 编程社区指数(The TIOBE Programming Community index)是编程语言流行度的指标,该榜单每月更新一次,指数基于全球技术工程师、课程和第三方供应商的数量。具体的计算方式见这里:https://www.tiobe.com/tiobe-index/programming-languages-definition/。

值得注意的是,TIOBE 指数并不代表语言的好坏,开发者可以使用该榜单检查自身的编程技能是否需要更新,或者在开始构建新软件时对某一语言做出选择。

下面再看一下PYPL编程语言排行榜,

PYPL PopularitY of Programming Language

注:PYPL(PopularitY of Programming Language Index ),即编程语言流行指数。其排名是根据在谷歌上的相关编程语言教程的搜索频率就行统计排名。也就是某项语言在 Google 上搜索频率越高,表示这项语言越受欢迎。

完整榜单地址:https://pypl.github.io/PYPL.html

从今年5月榜上可以看出,Python稳坐最受欢迎的语言,甚至与其他语言拉大了差距。

而历史数据显示在2018年4月,Python的关注度就超过了Java.

另外,Stack Overflow流量统计,2017年6月,Python第一次成为高收入国家Stack Overflow访问量最大的标签。2018年,Python超过Javascript成为最受欢迎的语言。 今年,Python依然是最受欢迎的标签并且百分比继续不断上升。

那些说 Python 不火的同学,肯定大跌眼镜吧。

Python是一种面向对象的解释型计算机程序设计语言,由荷兰人Guido van Rossum于1989年发明,第一个公开发行版发行于1991年。已不是一种年轻的编程语言,它突然火爆的背后到底有哪些深层原因呢?

Python是干什么的?
要找出python火爆的原因,我们就不得不先来了解python本身。Python 是一种面向对象的解释型计算机程序设计语言。Python的设计哲学强调代码的可读性和简洁的语法(尤其是使用空格缩进划分代码块,而非使用大括号或者关键词)。相比于C++或Java,Python让开发者能够用更少的代码表达想法。不管是小型还是大型程序,该语言都试图让程序的结构清晰明了。

与其他动态类型编程语言一样,Python拥有动态类型系统和垃圾回收功能,能够自动管理内存使用,并且支持多种编程范式,包括面向对象、命令式、函数式和过程式编程。除了其本身拥有一个巨大而广泛的标准库,Python还有全世界程序员不断共同贡献代码的丰富和强大的第三方库。它常被昵称为胶水语言,能够把用其他语言制作的各种模块很轻松地联结在一起。

Python 解释器本身几乎可以在所有的操作系统中运行。Python的第一个解释器CPython是用C语言编写的、是一个由社群驱动的自由软件,当前由Python软件基金会管理。

Python是纯粹的自由软件,源代码和解释器CPython遵循 GPL(GNU General Public License)协议。GPL是自由和开源软件领域最受欢迎的软件许可之一。Python因为受欢迎,以至于有多个语言开发的Python解释器。

     · CPython,官方的解释器。需要区别于其他解释器的时候才以CPython称呼。这是最常用的Python版本。

· Jython(原名JPythonJava语言实现的Python,现已正式发布)。Jython可以直接调用Java的各种函数库。

· PyPy(使用Python语言写的Python)

· IronPython(面向.NET和ECMA CLI的Python实现)。IronPython能够直接调用.net平台的各种函数库。可以将Python程序编译成.net程序。

· ZhPy(周蟒,支持使用繁/简中文语句编写程序的Python语言)

Python这么火的内因有以下几点

1.入手快:

Python语言相对于其他编程语言来说,属于比较容易学习的一门编程语言,它注重的是如何解决问题而不是编程语言的语法和结构。所以,已经有越来越多的初学者选择Python语言作为编程的入门语言。

Python的语言没有多少仪式化的东西,所以就算不是一个 Python 专家,你也能读懂它的代码。Python的语法里面条条框框以及特殊的处理场景要少得多。它所专注的并非语言表现的丰富程度,而是你想要用你的代码完成什么。

2.颜值高:

Python语言力求代码简洁、优美。在 Python 语言中,采用缩进来标识代码块,通过减少无用的大括号,去除语句末尾的分号等视觉杂讯,使得代码的可读性显著提高。它使你能够专注于解决问题,而不用太纠结编程语言本身的语法。

Python能用少量的代码构建出很多功能。能带给所有开发者一种快速的学习体验。通过实践,你可以在最多两天之内轻松实现一个具备基础功能的游戏(而这还是在对编程完全不了解的情况下)。另外一些让Python
成为一门引人注目的编程语言的因素就是它的可读性和高效性。

3.有内涵:

Python语言号称自带电池,寓意是 Python 语言的类库非常的全面,包含了解决各种问题的类库。无论实现什么功能,都有现成的类库可以使用。合理使用Python 的类库和开源项目,能够快速的实现功能,满足业务需求。

Python多才多艺,可以被应用于如今你所能想得到的相当多的软件开发和操作场景。要管理本地或者云基础设施吗?Python可以。开发网站? OK,它也能行的。需要处理一个SQL 数据库? 可以。需要为 Hive 或者 Pig 定制一个功能?能做到。只是想为自己构建一个小工具?Python 就是最好的选择。需要一门支持面向对象设计的语言? Python 的特性就能满足啦。简而言之,将 Python 了解得更加深入一点点,就能让你具备可以适应范围更宽泛的工作角色的技能。

4.效率高:

Python语言因为有了丰富强大的类库,所以,Python 的开发效率能够显著提高。实现相同的功能,Python代码的文件往往只有 C、C++ 和 Java 代码的 1/5~1/3。这也是为什么各大互联网公司广泛使用Python 语言的原因。

Python 拥有最成熟的程序包资源库。一旦你了解了该语言,就可以利用上这个平台。Python拥有超过
85,000 个 Python 模块和脚本的资源库,你拿过来就立马可以使用。这些模块向你的本地Python 环境分发已经预先打包好的功能,可以用来解决各种诸如数据库处理,计算机视觉实现,像维度分析这样的高级数据分析的执行,或者是构建REST 风格的 web 服务这些问题。

Python + GItHub 社区的各种开源工具包就好比一个军火库,里面什么武器都有,完全取决于使用者怎么组装这些武器。例如: 数值计算工具:NumPy,SciPy; 符号计算工具:SymPy; 机器学习工具:Scikit-Learn,XGBoost,lightGBM,catBoost,PySpark; 深度学习工具:TensorFlow,PyTorch; 时间序列工具:FbProphet; 数据分析工具:Pandas; 地图分析工具:folium;web开发工具:Django,Flask; 可视化工具:matplotlib; 图计算工具:networkx。 另外,各种数据库例如 Redis,MySQL,influxDB 等都有相应的 Python API。

5.应用广:

工程师可以使用 Python 做很多的事情。例如,Web 开发、网络编程、自动化运维、Linux系统管理、数据分析、科学计算、人工智能、机器学习等等。

Python 广泛用于数据科学领域。不管你从事的是什么工作,数据都会是其中的一部分。IT,软件开发,市场–
它们都深度地关乎数据且对于智慧求之若渴。很快数据分析技能就会像编码技能一样的重要,而 Python 在两个领域都占有重要的地位。Python 紧挨着 R 语言,都是现代数据科学中最常被使用的语言。事实上,在数据科学领域,Python 的职位职位需求超过了R 语言。你在学习 Python 时发展出来的技能将会直接转换并被用来构建起自己的这些分析技能。

6.全开放:

Python 是跨平台且开源的。

Python 可以跨平台运行,并且已经开放源代码超过20年的时间了,如果你需要代码能同时在Linux,Windows 以及 macOS 上跑起来,Python 就能满足要求。此外,有数十年的修修补补以及不断完善做后盾,可以确保你能够随心所欲地运行自己的代码。

上述就是Python这么火的内因,下面我们就来看看Python在国内外这么火的外因

Python火爆的外因

12~14年是云计算最火的几年,大批创业公司和巨头挤破头地进军云计算领域,大家都在做IAAS,最著名的云计算开源平台OpenStack

就是基于Python 开发的,为此催生出不少Python 岗位

14~15年是「大众创新,万众创业」口号喊得最响两年,全国大街小巷似乎人人都是创业者,O2O、P2P产品如雨后春笋般冒出,什么语言最适合快速搭建原型?当然是Python,Python 的开发速度一个顶仨。

16~17年人工智能火遍大江南北,AlphaGO 的出现让业界为之兴奋,人工智能不再是概念,而人工智能、机器学习的首选语言就是Python。

这两年特别是网络爬虫火得一塌糊涂,10个写爬虫的9个在用Python,曾经有一段时间知乎的Python话题全部被爬虫相关的帖子刷屏,为什么爬虫这么火,这个还是跟大数据有关,因为数据挖掘、分析、机器学习、人工智能都需要大数据的支撑,而真正有大数据的厂商没几个,所以小厂不得不通过爬虫去获取数据。

Python 是一门兼具简单与功能强大的编程语言,它专注于如何解决问题、自由开放的社区环境以及丰富的第三方库,无需浪费时间去造轮子,各种Web框架、爬虫框架、数据分析框架、机器学习框架应有尽有,拿来即用,如果你不知道去哪找第三库,可以看看 awesome-python

Python 的发展完全是由社区自我驱动的,喜欢Python的原因很简单,因为它确确实实给开发者带来了愉悦的编程体验。

正是因为Python占据了天时地利人和,所以才让Python在短短几年内跻身世界编程语言最受欢迎的语言之一。未来,「人生苦短,我用 Python」或许不再是网络上的流行语,而是成为人们的共识。那么你做好了转行Python的准备吗?如果还没有,那么可以关注我们的后续文章。

接触早,好不好?

有很多的家长会困惑,让小朋友这样早的接触编程,会不会将来只能做我们通常意义上的“程序员”?我们想要指出的是,正是不愿意仅仅停留在程序员的一层, 当小朋友接触编程之后,如果他们兴趣不大,将来就可以把编程作为一个工具,帮助他们分析问题。如果他们很感兴趣,他一定会希望用编程来做一些更高级的事情,比如设计一个游戏,或者用Python自动玩游戏,比如在学习和工作中自动处理上千的表格和文件,自动登录系统处理问题,解决问题。解决的问题越大,成就感也就会越大。尽早接触编程,对孩子是一个很好的机会去看看更广阔的天地。

Python Program Happy Mother’s Day

Happy Mother’s Day to all Mom

Here is a the python way of saying “Happy Mother’s Day”

Let’s put these code in pycharm and run it for Mom.

first one can run on trinket.io

motherday1.py

print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(12, -10, -1)]))

result:

            veLoveLov           veLoveLov               
        eLoveLoveLoveLove   eLoveLoveLoveLove           
      veLoveLoveLoveLoveLoveLoveLoveLoveLoveLov         
     veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL        
    veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLov       
    eLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove       
    LoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL       
    oveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLo       
    veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLov       
    eLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove       
     oveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove        
      eLoveLoveLoveLoveLoveLoveLoveLoveLoveLove         
      LoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL         
        eLoveLoveLoveLoveLoveLoveLoveLoveLove           
         oveLoveLoveLoveLoveLoveLoveLoveLove            
          eLoveLoveLoveLoveLoveLoveLoveLove             
            veLoveLoveLoveLoveLoveLoveLov               
              oveLoveLoveLoveLoveLoveLo                 
                LoveLoveLoveLoveLoveL                   
                   LoveLoveLoveLov                      
                      LoveLoveL                         
                         Lov                            

Then, we need add some color for this heart. Since we are import modouls, following program can only run in pycharm. If you want to know how to download pycharm, please check on this link Python environment guide [Pycharm IDE] .

motherday2.py

import colorama
RED = colorama.Fore.RED + colorama.Style.BRIGHT
print(RED+'\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(12, -10, -1)]))

If you receive error on missing module colorama, you know there are 2 ways to install this module as we tought in class. one way is : pip3 install colorama

Next, add more colors , flowers, sleep delay, random space in left, and loops with dynamic colorful result

motherday3.py

import colorama
import time
from random import *

RED = colorama.Fore.RED + colorama.Style.BRIGHT
CYAN = colorama.Fore.CYAN + colorama.Style.BRIGHT
GREEN = colorama.Fore.GREEN + colorama.Style.BRIGHT
YELLOW = colorama.Fore.YELLOW + colorama.Style.BRIGHT
MAGENTA = colorama.Fore.MAGENTA + colorama.Style.BRIGHT

# Print header
for i in range(1, 35):
print('')
# *s position
heartStars = [2, 4, 8, 10, 14, 20, 26, 28, 40, 44, 52, 60, 64, 76]
# Position of space
heartBreakLines = [13, 27, 41, 55, 69, 77]
# Empty column position of rose
flowerBreakLines = [7, 15, 23, 31, 39, 46]

# add new column
def addSpaces(a):
count = a
while count > 0:
print(' ', end='')
count -= 1

# add new line
def newLineWithSleep():
time.sleep(0.3)
print('\n', end='')

play = 0
while play == 0:
Left_Spaces = randint(8, 80)
addSpaces(Left_Spaces)
# draw heart
for i in range(0, 78):
if i in heartBreakLines:
newLineWithSleep()
addSpaces(Left_Spaces)
elif i in heartStars:
print(RED + '*', end='')
elif i in (32, 36):
print(GREEN + 'M', end='')
elif i == 34:
print(GREEN + 'O', end='')
else:
print(' ', end='')
newLineWithSleep()
addSpaces(randint(8, 80))
print(CYAN + "H a p p y M o t h e r ' s D a y !", end='')
newLineWithSleep()
newLineWithSleep()
Left_Spaces = randint(8, 80)
addSpaces(Left_Spaces)
# draw flower
for i in range(0, 47):
if i in flowerBreakLines:
newLineWithSleep()
addSpaces(Left_Spaces)
elif i in (2, 8, 12, 18):
print(MAGENTA + '{', end='')
elif i in (3, 9, 13, 19):
print(MAGENTA + '_', end='')
elif i in (4, 10, 14, 20):
print(MAGENTA + '}', end='')
elif i in (27, 35, 43):
print(GREEN + '|', end='')
elif i in (34, 44):
print(GREEN + '~', end='')
elif i == 11:
print(YELLOW + 'o', end='')
else:
print(' ', end='')
print('\n', end='')

result:

The future is here (1)-Technological change

The future is here.

Companies that are driven by technology and use algorithms to make decisions are growing wildly, leaving veteran Internet giants in panic.

Replace people with algorithms, this is happening.

Before we read the news, Alpha Dog Go defeated humans, and AI played Dota to defeat quasi-professional players.

On the one hand, we are worried about being replaced by artificial intelligence. On the one hand, we feel that the day of being replaced is far away: artificial intelligence plays Go, but it is not enough to be productive in many fields.

The premise of “very distant” is: artificial intelligence wants to imitate people, and then surpass people, which is difficult. Because of human emotions, thinking is something that machines can hardly simulate.

Humans are arrogant here.

Because as long as one kind of productivity is more efficient than the old one, then the old one will be replaced.

Algorithms surpass humans, that is, they surpass humans without imitating humans at all.

“Flow” technological change

Regarding the issue of “flow”, there have been three obvious stages in the last 20 to 30 years.

(1) First stop, flooding traditional media

The 1990s were the golden age of newspapers and television media. This is the earliest time when people come into contact with a single medium.

During that time, the media and advertising companies were the most beautiful places. A lot of talents are there.


(2) At the second stop, someone started to think about the scene and experience

Here, the leader will be the product manager. They start to think about “scenes” and “interactions”-I think what users should do in this situation will have a better experience.

They are responsible for thinking: I think users should have a better experience in this situation.

Even, they said: Users don’t know what they want, I’ll define what users want.

Define what the user wants. And it also defines success as genius.

To make products, we must rely on “users think this is better”, but not “I think, users will think this is better.”

So, how do you perceive “user perception”? Three ways:

① Talk to the user.

② As a user, experience it yourself.

③ User behavior data.

Traditional Internet companies make use of ① and ②, and they call this “user research”.

They use “true smart people, all work hard.” To praise excellent product managers. This means that the smarter and more experienced you are, the more you have to walk into users and get to know them.

Otherwise, it is easy to fall into empirical judgment-“I think, users will think.”

And this judgment is often not credible.

This is because the user’s behavior data is not collected enough, not good enough, and the algorithm design is not beautiful enough. They believe that their judgment of eyes and hearts is better than that of data algorithms.

However, the data will get better because it gets better faster than people grow faster.

When it becomes more credible than human experience judgment, we will come to the third stop.

(3) The third station is algorithm-driven.

Design from the aspects of data sampling, data utilization, and algorithm construction.

This is a change:

① Product thinking scenarios and interactions; engineers to implement; users give feedback; return to the first step.

② Engineers design algorithms; engineers request data; product thinking how to get data; product design scenarios and interactions; engineers to implement; data to give feedback; return to a previous step.

Later, we will continue to give examples.

Technological change is happening now

When the algorithm’s ability is getting stronger and stronger, until one day it breaks a threshold, which is the average effect of human work.

Then the algorithm will kill most people’s work in an instant.

And the remaining handful of people will be killed by the algorithm a little bit.

Because the evolution of the algorithm is faster than human learning.

The old productive forces have been replaced by ruin. This kind of thing has happened too many times in human history, especially in recent years.

People started spending online.

Things were gentle at the beginning: some companies began to work harder to recruit algorithm engineers.

Just like now, what is happening.


We have talked about a lot of content in this manuscript, but the core sentence is just one: the algorithm replaces people, and it happens in the present.

If it is replaced, it is an inescapable fate. So as an individual, how should one deal with this matter. -Embrace technology.


To add a case, Netflix.

Maybe you haven’t heard of it, it’s simply the one who made “House of Cards”.

But this company is not simple. In June of this year, its market value was more than 180 billion US dollars, and its price-earnings ratio exceeded 300 times.

Even the same industry, the traditional spoiler Disney, has a market value of $ 168 billion.

This is an explanation of the price-earnings ratio. The price-earnings ratio of general technology companies is tens.

But netflix can reach three hundred.

The meaning behind it is that one side is high risk, and the other side is: it is overvalued by capital, and capital likes it.

So the question is, what business is such an entertainment giant doing?

Netflix was the earliest retailer. Later, it transformed into what it is now.

It shows people, but also makes plays, such as the house of cards.

The difference is that all its users are paid users. It’s just that you have a one-month free trial.

It does a very good recommendation algorithm. Based on what you have seen, based on your preferences, based on your identity information … to recommend content to you.

Now it’s time to talk about what it does with algorithms.

Use algorithms to intervene in content selection and production.
Director David Finch once took the adapted playbook of “House of Cards” and found many TV stations in the United States, but none of them dared to pay for it. No one can say whether an old play 20 years ago still has a market.

Netflix conducted a “TV drama consumer habits database” analysis, they found that the audience who likes to watch the 1990 BBC version of “House of Cards” is also a fan of the ghost director of “Social Network” and “Seven Deadly Sins” David Finch, They are also loyal fans of Oscar-winning actor Kevin Spacey. With powerful big data analysis support, Netflix can fully predict the audience and market response, integrate fans of the original “House of Cards” and Kevin Spicer and David Finch fans, and invest in the new version. House of Cards, a hit.

Use algorithms to make interest recommendations.

Netflix has been holding large competitions to recruit talents to improve its data mining processing capabilities. At the end of 2005, Netflix set up a million dollar prize collection algorithm and architecture that can increase the performance of its recommendation system by 10%. In the end, a team of engineers, statisticians, and research experts won a million prizes and successfully increased the recommendation efficiency of the Netflix movie recommendation engine by 10%.

Corresponds to the utilization algorithm. Many times, algorithms are also using people.

People need benefits, and algorithms need data—a large amount of data that is easy to calculate.

Netflix also made a lot of efforts to feed the data to the algorithm.

Infrastructure
In 2010, Netflix completed two data migrations, the first was to migrate the Netflix data center to Amazon AWS, and the other was to migrate the Oracle database to SimpleDB. By 2011, it was migrated from SimpleDB to Cassandra. Using the routing configuration provided by Cassandra, the cluster can be deployed on multiple continents.

Modification of product form

They eliminated the five-star scoring mechanism and changed it to good and bad, a single judgment.

They cancel the user comment function.

This is done to make the data cleaner and reduce interference factors.

In the eyes of traditional product managers, this is a bold decision.

But netflix did it because the starting point was different. Netflix needs to organize the data and feed it to the algorithm to allow the algorithm to produce benefits.

They trust algorithms and outperform human judgment.

Then they succeeded.

Python environment guide [python , Pycharm IDE]

In beginning of our Python Programming Basic class, we use web version python code you run on trinket. You may ask “How can I run Python code on my computer out of the trinket environment?”. Yes, this is a good question. We learn Python to be used in a real environment on our local computer. Next, let me introduce you to the common methods of building a Python environment. In our later part Python Programming Basic class and Python Crawler Advance class, we use Pycharm as our local python IDE.

PyCharm is a cross-platform editor developed by JetBrains. Pycharm provides all the tools you need for productive Python development. Among many editors, Pycharm is relatively friendly to new users. On the one hand, it will automatically complete the code. For example, if you write the front quotes, it will automatically fill in the back quotes; on the other hand ( More importantly) It will prompt you when the code is written. Therefore, the first article we recommend in the editor recommends Pycharm.

This article is divided into three parts, namely Installing Python, Third-party library installation and Installing Pycharm and use

Below are the detailed steps for installing Python and PyCharm

Installing Python

Step 1) To download and install Python visit the official website of Python https://www.python.org/downloads/ and choose your version. We have chosen currently latest Python version. Click the Download button to enter the download page, there are a variety of versions at the bottom to choose from.
We choose the appropriate version according to our system type (32-bit or 64-bit) and click to download, generally we choose executable installer. The differences between the various versions are:
embeddable zip file: embedded version, can be integrated into other applications
web-based installer: network installation
executable installer: executable file (* .exe) installation
We selected Windows x86-64 e installer here, double-click to open after the download is complete, you can see the interface as shown below:

Step 2) Once the download is complete, run the exe for install Python.

Note: first check all the boxes. The Add Python 3.8 to PATH circled in the figure must be checked, otherwise ‘python’ will give error after installation. then click Install Now

Step 3) You can see Python installing at this point.

Step 4) When it finishes, you can see a screen that says the Setup was successful. Now click on “Close”.

Step 5) After closing the installation interface, we use the win + r shortcut key to open the run window, enter cmd in the run window, and click the OK button to open the command prompt, which is the command line.

Step 6) Enter python in the command prompt window and press Enter. When you see the version information of Python, you have entered the Python interactive environment. Then we can enter the python code after >>> to execute.

Install on Mac
Mac generally comes with Python, but the version is older. Next, let ’s talk about how to install the latest one. Choose one of the following two methods:

Go to the official website to download and install like Windows;
Install through Homebrew. If Homebrew is already installed, simply execute in the terminal:

brew install python3

Manually run python program in command line is hard. The more recommended way is to use an editor or IDE to create a py file to write and run code. A good coding tool can greatly improve coding efficiency. Here, we recommend using vscode or pycharm.

Third-party library installation


The reason why Python is so powerful is inseparable from its rich third-party libraries. Next we look at how to install third-party libraries.

Python uses pip to manage third-party libraries. Python 2.7.9 or Python 3.4 and above all come with pip tools, which we can use directly.

First, we open the command prompt window by the method mentioned above, then enter the name of the third-party library pip install and press Enter to start the installation. For example, we want to install the requests library, just type

pip install requests

and then press Enter key to install

It should be noted that the command is entered directly in the command prompt window(or in Terminal window in pycharm). Many students open the command prompt, enter python, and then install the command. This is wrong.

Installing Pycharm and Use

Step 1) To download PyCharm visit the website https://www.jetbrains.com/pycharm/download/ and Click the “DOWNLOAD” link under the Community Section, which is free.

Step 2) Once the download is complete, run the exe for install PyCharm. The setup wizard should have started. Click “Next”.

How to Install Python on Windows with Pycharm IDE

Step 3) On the next screen, Change the installation path if required. Click “Next”.

How to Install Python on Windows with Pycharm IDE

Step 4) On the next screen, Check all boxes first, which create a desktop shortcut, associate .py and add PATH. Then click on “Next”.

How to Install Python on Windows with Pycharm IDE

Step 5) Choose the start menu folder. Keep selected JetBrains and click on “Install”.

How to Install Python on Windows with Pycharm IDE

Step 6) Wait for the installation to finish.

How to Install Python on Windows with Pycharm IDE

Step 7) Once installation finished, you should receive a message screen that PyCharm is installed. (After the installation, the computer will be required to restart, select the one above to automatically restart, select the next one to manually restart. choose either one is ok). click “Finish”.

How to Install Python on Windows with Pycharm IDE

Step 8)  Find your new installed PyCharm program on desktop . double click to Open it.

Step 9)  After you open Pycharm, you will be asked if you want to enter the previous settings. For the first installation, select “Do not import”

How to Install Python on Windows with Pycharm IDE

Step 10) Privacy policy, please check if you have no patience, then continue

Step 11) Click Create New Project, or Open your folder. We suggest create a folder on desktop name python, then open the folder python on desktop. In our class, we need to create at least 3 folders under python: python1, python2, python3 for your diffrent levels of python class.

Step 12) If you haven’t create folders in pycharm before, it is easy, Just right click on python folder in left side, select New, then select Directory .

Step 13) type in name of directory , for example, python1, press Enter . Create python1 folder

Step 14) Right click on python1 folder in left side, select New, then select Directory . type in name of 1st class in Python Programming Basic class, 1print function and variables (You can go to 1st Basic class and copy the class name from lemonthy.ca), press Enter

Step 15) Right click on 1print function and variables folder in left side, select New, then select file. type in name of 1st execs in Python Programming Basic class, 101No_quotes.py (You can go to 1st Basic class and copy the exec name from lemonthy.ca), press Enter

Step 16) double click on new file 101No_quotes.py. type your code in 1st class. There are 3 ways to run the code: 1. right click on empty space of code on screen , then select Run 101No_quotes.py . 2. or you can click green triangle run button on top right side of toolbar. 3. you can press shortcut key Ctrl+Shift+F10

The last is our intergrated Anaconda. Anaconda is a large collection that includes Python and its commonly used tools and modules. For beginners, just installing Anaconda is enough! Please google how to install Anaconda . and follow the instruction to install

Because of him, Python has become the most popular programming language

“I am tired and need a long rest”

In a July 2018 mailing list post titled “Power Transfer”, Guido van Rossum wrote:

I don’t want to worry about PEP anymore, and despite the hard decisions I made, I still find that many people are still dissatisfied.



Guido van Rossum screenshot of some emails


“PEP” is a Python Enhancement Proposal. Guido will personally sign and confirm each PEP, which is one reason why he is called a benevolent dictator. In sharp contrast to this, similar improvements to PHP were all done by voting.

Guido is undoubtedly better at Python-but on the third day after the acceptance of PEP 572, feedback from flakes flew like this, making this 62-year-old famous engineer overwhelmed.




He was born in Haarlem, a small Dutch city, and graduated in mathematics and computer science from the University of Amsterdam in the Netherlands in 1982. Then he entered the Mathematics and Computer Science Center in Amsterdam and became a programmer.

At CWI, Guido had been working for 12 years, and did not leave until 1994. During Christmas in 1989, in order to pass the boring Christmas holiday, Guido determined to develop a new script interpreter as an inheritance of the ABC language.

The reason why I chose Python as the name of the program is because he really likes a British soap opera: “Monty Python Flying Circus”. He thinks the word Python is very interesting and very attractive. From the name of Python, it can be seen that Guido loves it.

Since the birth of Python in 1989, this straightforward engineer has spent 30 years of hard work to continuously improve it, and this is where Python is today.


Guido took a photo with everyone wearing a T-shirt with the words “Life is short, I use Python”


I will still be here

“As an ordinary core developer, I will still be there all the time, and I can still guide people, maybe more time.”

He added: “But I basically gave myself a permanent vacation improper BDFL (Benevolent Dictator For Life), and then you are on your own.”

No matter how the staff of the Python team changes, it is undeniable that more and more people use it.


July 2018 programming language index list
CodingDojo recently ranked Python as the second most popular skill in developer recruitment ads. Stack Overflow’s 2018 developer survey ranked Python as the seventh most popular “programming, scripting, and markup language”, ahead of C #, Ruby, and PHP.

Facts have proved that Guido’s achievements are extraordinary: Python has become one of the most used languages ​​in the world.

It is widely used in various fields such as machine learning, artificial intelligence, scientific computing, finance, games, mathematics, and physics. Various universities and major companies including Google, Facebook, Microsoft, Alibaba, etc. are also using Python.

“Life is short, Python is the shore”

Python is an ideal beginner’s language and is also used in heavyweight enterprise applications.

Its design is very simple, elegant and clear.

The most important thing is that Python is the first programming language of artificial intelligence-no one can shake its advantages in artificial intelligence.


The Python language is widely sought after by programmers, and its employment and salary have not disappointed.

In fact, as Guido once wrote in a letter to readers:

Python is a language that makes people’s lives easier. It allows you to focus on the job at hand, rather than entangled in every obscure detail of the computer system.

Many people are stumped by understanding binary?

When it comes to the rounding system, everyone should be familiar with decimal, because most of life uses decimal, and we have learned the four arithmetic of decimal since elementary school. Since humans are so familiar with decimal, why don’t computers use the same decimal as humans?

Binary representation
The bottom layer of the computer is composed of a bunch of electronic circuits. Let’s take a look at the simplest circuit example:



You may have guessed the function of the circuit above:

When the switch is closed, the light bulb is on
When the switch is off, the bulb is off
We can use the closed switch to represent 1, and the open switch to represent 0. This is a simple binary circuit.

Similarly, the magnetic disk is actually composed of many small magnets. The N pole of the magnet indicates 1, and the S pole indicates 0. So each small magnet has two states of 0 and 1 just like a switch.

Early components can only represent these two states (such as on and off, N and S, etc.), which is why computers use binary. Think about it, if the computer uses decimal, this electronic component must have ten states, how complicated it should be!

Binary bits and bytes
However, the number that can be expressed with only one digit is limited. For example, binary is 0-1, decimal is 0-9, and hexadecimal is 0-15. Of course, a single number cannot meet our needs. If a computer can only handle the range of 0-1, humans can only handle the range of 0-9, and a disk can only store the two numbers 0 and 1, then social development may be early. Just stand still!

Smart humans choose to count with more digits, in decimal we can use eight digits to represent numbers within 100 million, the same is true for binary. We generally call the 8-bit binary a byte. One byte can represent 0-255 values ​​(think why 255?). If you want to process more information, you need more bits. For example, a 64-bit CPU can process more and faster information than a 32-bit CPU.

The representation of “3” in binary
Now that you know so much, how do you represent binary 3 in decimal?

In fact, this problem is the same as “9 + 2 in decimal”. That is through carry. Decimal is one for every ten, and binary is one for every two.

Now let’s see how to express 3: in binary:

The above picture clearly shows the calculation process in binary, is it the same logic as decimal decimal?

In a byte (8-bit binary number), the weight of each digit is different, namely 1, 2, 4, 8, 16, 32, 64, 128. Similarly, decimal is one, ten, one hundred, one thousand, ten thousand, etc.

Now, do you already understand binary?

The future is here (2)-Embrace AI

Artificial intelligence

In the past few years you have heard the words “artificial intelligence” in many different places: Alpha Go, which can play Go; Google’s voice assistant, which can call to order food; Amazon’s Alex, which can open TV, play music .

But in fact, very few people come forward to explain clearly, what is artificial intelligence?

A streamlined answer is this: Artificial intelligence is the use of machines to do things that only people could do in the past. Scientists have classified these things: reasoning, planning, learning, communication, perception, movement.

Use machines to do things that only people could do in the past. This sentence sounds simple, but if you look at history, you would not think so.

Since the birth of human civilization, we have probably experienced: the Stone Age, the Iron Age, the Machine Age, the Electrical Age … Today, the most critical milestone should be the “Machine Age”, which is what we often see in history textbooks “The Industrial Revolution”.

Why do you say that? All along, as the creators of value, we have always had two ways of creating value: one is manual labor and the other is mental labor. When the industrial revolution comes and we enter the machine age, manual labor is less important and the income of mental workers is improved. Everyone started to enter the factory and into the office.

“Machines do things that only humans could do in the past”, and humans can only play the abacus of mental work. What makes a person is what we need to spend more time thinking about.


Artificial intelligence technology
In the 1940s, almost at the same time as the computer was invented, some people began to study this field. Since then, it has been obscured.

There is a law in the development of technology: the last month is still unknown, but once it breaks through a certain critical point, you can see it in life next month.

Things started to change dramatically more than ten years ago. In 2006, the emergence of deep learning algorithms, which pushed artificial intelligence to take a big step forward. Because of this big step, the rapid development of artificial intelligence like a blowout seems to have entered thousands of households overnight. All the cases we mentioned earlier all come from this.

In fact, since 2006, no underlying technology with such a huge influence has appeared. However, we have heard more and more information about “artificial intelligence” in recent years. This is because technology is applied to life.

In the future, there will be more applications. In it, it contains huge opportunities.

Let ’s take an example: we said earlier that artificial intelligence requires machines to do things that only humans used to do. There is a part in it called “perception”. In “perception”, there is a very important part is “image recognition”. In layman’s terms, it means that the computer can “perceive” the image like a human, and it can understand the picture.

In the old camera, it could not understand the picture. In its eyes: the rose is just a combination of a bunch of images and shapes. It is no different from the moon and no different from the bear.


You may be wondering, what is an algorithm? To make an analogy: We humans need “learning methods” to learn things. The same is true of computers, and we can understand “deep learning algorithms” as “learning methods” of computers. In the past, it has never had a good learning method. Now that we have it, we can learn something from it.

Let’s take a picture of 10,000 roses to the computer and tell it: Remember, this is a rose. With the help of algorithms, the computer calculates the common law of these 10,000 roses. It learns and remembers this law. When we go to show the computer the tenth and a thousandth photo. It makes a judgment: this picture basically conforms to the law I remembered before, and it has a 99% probability of being a rose.

So, it said: This is a rose.

Let the computer say: this is a rose. This may seem like a trivial thing, but it is a beginning.

We feed it more data: roses, ladders, faces, bread … let it calculate, learn, remember. Image recognition is like this: from now on, the computer can read the pictures.


Just because the computer can’t read the pictures, we still have to find ways to apply the technology to life scenes, so that it can create value.

As we said before, unmanned shopping requires image recognition technology: responsible for identifying the goods taken by the customer, identifying the customer ’s face for security, and responsible for scanning the code to complete the payment … Below, I want to give you a few A case: An image recognition technology alone, in what areas can it be used.

It can be used to fight pesticides.

With image recognition technology. You can use a drone with a camera to spray pesticides instead.



In our eyes, the farmland looks like this:


But in the eyes of drones, things look like this:



Which is the weed, which is the crop, at a glance. Pesticides are only applied where they should be. In this way, one is to improve the efficiency. It takes about two hours for two drones to spray pesticide on a farmland of about 100 acres. One is to reduce pesticide residues, which can save more than 90% of pesticides compared to the previous flooding scheme.

Another scenario is medical. As our standard of living improves and the average life span is extended, the incidence of cancer also rises. Normally, we go to check the body, to take a film, and then the doctor took it and told you: I am afraid it is not a cancer.



But now, we can let the computer do the movie. In fact, at present, artificial intelligence is already more powerful than humans in identifying early cancer.

Here we have to think about something: a doctor who wants to grow up to be able to diagnose cancer has to read many years of books and accumulate years of clinical experience. But for machines, this cost is too low.

You can see that the machine does not need to imitate the way people do things, the machine only needs to imitate, or even surpass the results of people doing things, which is enough.

You can also see that it is also an image recognition technology, which can be applied to various seemingly unrelated scenes. At this time, it can create great value. We can get an equation: artificial intelligence = algorithm + data + application.

Faced with artificial intelligence, what can we do?

According to this equation, we can play, in this wave of opportunities in artificial intelligence, what can we do?

Algorithm, this is a good idea. But the threshold is quite high. You have to learn the knowledge of mathematics and computer science, at least you have to read a research knowledge. From shallow to deep, the relevant content will probably be: Python programming, crawlers, data mining, advanced mathematics, machine learning, deep learning …

Data … Doing artificial intelligence does require a large amount of regular data. However, in the hands of ordinary people, it is difficult to have a large amount of data that can train algorithms. These data are often controlled by large Internet companies, such as: Google has search data, Facebook has social data, and Amazon has business behavior data …

Big companies hire high-paying talents for algorithms, and big companies have data. So, as you can see today, artificial intelligence technology is basically provided by these big companies. With the help of data and algorithms, Google and Facebook provide precise advertisements, earning tens of billions of dollars in profits each year; Amazon ’s cloud computing provides technical services to countless small and medium-sized companies, and supports the market value of nearly trillions of dollars.

But this does not mean that ordinary people have no chance in front of artificial intelligence. At least for applications, there is still much to be done. Moreover, the sooner you participate, the better your first-mover advantage.

You only need to know some basic programming skills, you can call the artificial intelligence technology that has been developed, and apply it to your industry. Let technology replace and help people to work. It can reduce costs and increase profits, it is profitable. It’s like applying image recognition to agriculture, medical treatment, etc.

Do technology or application? This is an issue we need to consider now. But there is a certain proposition-programming, which should be learned. If our goal is to learn to transfer existing technology and develop programming thinking. That’s actually quite simple …

And learning to program is more than artificial intelligence. You can use code to automate many of your usual tasks: image processing, document processing, market analysis, web crawlers, data analysis …

Choose Python

With so many programming languages, which shovel should I choose?

Answer, that is what you have already contacted, Python.

There are many programming languages, but if the purpose of learning programming is to participate in the wave of artificial intelligence, then the first choice is Python. Choosing Python is not only safe but also necessary.

After all, it is the leading language in the era of artificial intelligence, which is something that has been agreed in the technical world.

The Python language helps artificial intelligence develop faster, and the development of artificial intelligence drives more people to learn Python. From beginning to end, they are complementary to each other.


(The fifth annual programming language list released by the International Federation of Electronic and Electrical Engineers, Python tops the list.)

Not only that, Python has a dominant position in the most popular applications such as big data analysis, machine learning, cloud computing systems, web development (such as Facebook / Google, all developed in Python), game scripts … and so on.

The reason for this result is determined by the characteristics of the Python language:

    It’s simple enough

    To achieve the same function, C ++ requires 1,000 lines and Java requires 300 lines, but Python may only need 20 lines.


    It is easy to learn and easy to read

    Python language is highly similar to human language. Mastering the basic grammar of Python is as fast as a few days and as slow as 1-2 weeks. Almost no comments are required to allow you to read Python code. Next, you can use it to call existing technologies to implement your own projects.

    It acts as a glue language, which is convenient for people from different industries to collaborate

    The research and development of artificial intelligence requires the cooperation of people from different industries, not only developers, but also scientific researchers and creative talents in different fields.

    Python is cross-platform and runs on systems such as windows, mac, linux, etc. It is particularly easy to learn. Everyone can package their own code very conveniently, and others can easily call it without reading it.

    These characteristics make the cost of collaboration extremely low.

Learning artificial intelligence starts with Python.