标签:pen begin lease 学习 个数 log circle 输入 yellow
1,Hello world!
>>> print("hello world")
hello world
2,简单交互
>>> name=input("please input your name:")
please input your name:junjun
>>> print("{}同学,好好学习,天天向上!".format(name))
junjun同学,好好学习,天天向上!
3,用户输入三角形三边长度,计算三角形的面积
>>> a=float(input("输入三角形第一边长:"))
输入三角形第一边长:2
>>> b=float(input("输入三角形第二边长:"))
输入三角形第二边长:3
>>> c=float(input("输入三角形第三边长:"))
输入三角形第三边长:4
>>> s=(a+b+c)/2
>>> area=(s*(s-a)*(s-b)*(s-c))**0.5
>>> print("area=%0.2f"%area)
area=2.90
4,输入半径,计算圆的面积
>>> radius=25 >>> area=3.14*radius*radius >>> print(area) 1962.5
5,用户输入两个数字,计算并输出两个数字之和
>>> a=input() >>> b=input() >>> int(a)+int(b) >>>
6,画一组同切圆
>>> import turtle >>> turtle.pensize(2) >>> turtle.circle(10) >>> turtle.circle(40) >>> turtle.circle(80)

7,画一个五角星
import turtle
turtle.up()
turtle.goto(-100,100)
turtle.down()
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.left(144)
turtle.end_fill()

8,画一个全黄色的五角星
import turtle
turtle.color("yellow")
turtle.bgcolor("red")
turtle.fillcolor("yellow")
turtle.up()
turtle.goto(-100,100)
turtle.down()
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.left(144)
turtle.end_fill()

标签:pen begin lease 学习 个数 log circle 输入 yellow
原文地址:http://www.cnblogs.com/junjun21/p/7491198.html