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(), float(), round()”
First, let’s have a look at the following code, try to guess the meaning of input(), int(), round()
首先看看下面的代码,试着看看input(),int(),round()在一起有什么作用。
The running output is below:
运行结果如下:
1.round(variable, x) # means Rounding variable up to a certain x number of decimal digits.
round()可以将变量的小数点确定到第x位。
2.float()#convert a string to a decimal number
把字符串格式转化为小数格式。
Secondly, let’s use input(), float(), round() together, to calculate the average mark for students.
接下来,我们用input(), float(), round()放在一起,来计算同学们的平均成绩。
The running output is below:
运行结果如下:
So, you have learnt python float()’ and ‘round()’ in today’s lesson. See you next time.
今天,这节课里你学会了用 ‘float()’ 和 ‘round()’ 。下节课再见啦~