【MOOC嵩天Python语言程序设计】1.2 Python开发环境配置 实例

实例1:圆面积的计算

r = 25
area = 3.1415 * r * r
print(area)
print("{:.2f}".format(area))
1963.4375000000002
1963.44

实例2:同切圆绘制

import turtle
turtle. pensize(2)
turtle. circle(10)
turtle. circle(40)
turtle. circle(80)
turtle. circle(160)

在这里插入图片描述

实例3:五角星绘制

from turtle import *
color('red','red')
begin_fill()
for i in range(5):
    fd(200)
    rt(144)
end_fill()
done()

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章