一、输出Hello World
print("Hello Word")
二、求和运算
a1 = input("a1:") a2 = input("a2:") sum = float(a1)+float(a2) print("第一个数{0}加第二个数{1}的和是{2}".format(a1,a2,sum))
三、输入三角形的三边求面积
import math a1 = input("a1:") a2 = input("a2:") a3 = input("a3:") p =(float(a1)+float(a2)+float(a3))/2 d=float(p) area = d*(d-float(a1))*(d-float(a2))*(d-float(a3)) b=float(area) c=math.sqrt(b) print(c)
四、输入圆的半径,求面积
Circle = input("圆的半径 :") area = 3.14 * float(Circle)*float(Circle) print(area)
五、画没有颜色的五角星
import turtle a = 0 while a < 5: turtle.forward(200) turtle.left(144) a = a + 1
六、画黄色五角星
from turtle import *
fillcolor("yellow")
begin_fill()
while True:
forward(200)
left(144)
if abs(pos())<1:
break
end_fill()