Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'

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()在一起有什么作用。
Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'_第1张图片
The running output is below:
运行结果如下:
Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'_第2张图片
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()放在一起,来计算同学们的平均成绩。
Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'_第3张图片
The running output is below:
运行结果如下:Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'_第4张图片

So, you have learnt python float()’ and ‘round()’ in today’s lesson. See you next time.
今天,这节课里你学会了用 ‘float()’ 和 ‘round()’ 。下节课再见啦~
Python learning by case study@[April] (跟着April用真实案例学Python)-Lesson four-'round(), float()'_第5张图片
case 3 output

你可能感兴趣的:(python)