标签:for 没有 半径 3.1 break nbsp images png begin
一、输出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()
七、画同切圆
import turtle turtle.pensize(8) turtle.circle(10) turtle.circle(20) turtle.circle(40) turtle.circle(80) turtle.circle(160)
八、简单交互
name = input("输入姓名:") print("{}同学,学号Python,前途无量!".format(name))
标签:for 没有 半径 3.1 break nbsp images png begin
原文地址:http://www.cnblogs.com/lfsm/p/7483453.html