Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson three-'input()'

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:
首先,看下下面的代码:
case1-input
case 1 output
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?
下面,我们来猜猜下面的代码,有个地方的错误你发现了吗?
case 2 - input
case 2 - output
Why 6+7=67 ? How to solve the problem?
为什么 6+7=67?怎么解决这个问题?

case 2 -input and int
case 2-output-correct
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()’ 。下节课再见啦~
case 3 - input
case 3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值