Author: Notus(hehe_xiao@qq.com)
Create: 2019-02-13
Update: 2019-02-13
圆面积计算、打印斐波那契数列
环境
Python version: 3.7.1
1. 圆面积计算
代码如下(ex1.py)
'''
圆面积计算
@Author: Notus(hehe_xiao@qq.com)
@Python version: 3.7.1
@Date: 2019-02-13
@Update: 2019-02-13
'''
radius = 25
area = 3.1415 * radius * radius
print(area)
print("{:.2f}".format(area))
运行结果
$ python ex1.py
1963.4375000000002
1963.44
2. 输出不大于1000的斐波那契数列(ex2.py)
代码如下
'''
输出不大于1000的斐波那契数列
@Author: Notus(hehe_xiao@qq.com)
@Python version: 3.7.1
@Date: 2019-02-13
@Update: 2019-02-13
'''
a, b = 0, 1
while a <= 1000:
print(a, end=', ')
a, b = b, a + b
运行结果
$ python ex2.py
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987,