Python learning by case study@[April]
(跟着April用真实案例学Python)
Lesson three 第三讲
Python is one of the most popular programming languages in the world. It is necessary to grasp it before entering the workplace.
Python是世界上最流行的编程语言之一。 在进入职场前大家都有必要掌握这门语言。
TODAY’S FOCUS–“INPUT”
If you want your user to input their content, and we can get the input into our code.
如果你想让用户自己输入内容,而后我们可以将用户输入的内容放进代码里。
First, look at the following code:
首先,看下下面的代码:
As you can see from case 1, user’s input could be captured by the code, and the input could be saved as a variable,so that the code can use the variable.
从上面的案例1里,可以看到代码抓到了用户输入的内容,并存成了变量,从而被后面的代码所用。
Second, let’s guess the output of the following code. Something is wrong, could you find it?
下面,我们来猜猜下面的代码,有个地方的错误你发现了吗?
Why 6+7=67 ? How to solve the problem?
为什么 6+7=67?怎么解决这个问题?
Becaue input() will get string not integer,it is necessary to use int() change the string into integer.
因为input()抓到的内容会存成字符串格式,因此要用int()把字符串转换成整数类型。
So, you have learnt python ‘input()’ and ‘int()’ in today’s lesson. See you next time.
今天,这节课里你学会了用 ‘input()’ 和 ‘int()’ 。下节课再见啦~