Python输入输出练习,运算练习,turtle初步练习

  1. Hello World!
  2. 简单交互(交互式,文件式)教材P19
  3. 用户输入两个数字,计算并输出两个数字之和(尝试用一行代码实现)。
  4. 用户输入三角形三边长度,并计算三角形的面积:(海伦公式)
  5. 输入半径,计算圆的面积。
  6. 画一组同切圆
  7. 画一个五角星
  8. 画一个全黄色的五角星
  9. 画一组同心圆
  10. 画国旗上的五个五角星

1:

>>> print ("hello world")
hello world
>>> 

2:

name=input('输入姓名:')
print('{}好'.format(name))
print('{}好'.format(name[0]))
print('{}好'.format(name[1:]))

3:

print(float(input('第1个数:'))+float(input('第2个数:')))

4:

a=float(input('第一条边长:'))
b=float(input('第2条边长:'))
c=float(input('第3条边长:'))
p=(a+b+c)/2
s=(p*(p-a)*(p-b)*(p-c))**0.5
print(s)

 

5:

r=float(input('半径:'))
s=3.14*r*r
print('面积是:',s)

6:

import turtle
turtle.circle(10)
turtle.circle(20)
turtle.circle(40)
turtle.circle(80)

7:

import turtle
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)

8:

import turtle
turtle.color('yellow')
turtle.begin_fill()
turtle.fillcolor('yellow')
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.left(144)
turtle.forward(300)
turtle.end_fill()

9:

import turtle
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
turtle.penup()
turtle.goto(0,-150)
turtle.pendown()
turtle.circle(150)
turtle.penup()
turtle.goto(0,-100)
turtle.pendown()
turtle.circle(100)
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.circle(50)

10:

import turtle
turtle.bgcolor('red')
turtle.color('yellow')
turtle.begin_fill()
turtle.fillcolor('yellow')
turtle.penup() 
turtle.goto(-310,200)
turtle.pendown()
for i in range(5):
  turtle.forward(150)
  turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-150,250)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
       turtle.forward(40)
       turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-100,200)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
       turtle.forward(40)
       turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-110,130)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
       turtle.forward(40)
       turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-160,70)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
       turtle.forward(40)
       turtle.right(144)
turtle.end_fill()

 

posted @ 2017-09-07 18:54  ELsky  阅读(209)  评论(0编辑  收藏  举报