码迷,mamicode.com
首页 > 编程语言 > 详细

python练习9-7

时间:2017-09-07 11:59:03      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:import   put   begin   inpu   print   技术分享   down   from   for   

print(Hello world)
Hello world

2

name = input(请输入姓名:)
print(%s 同学,你好%name)
print(%s 同学,我觉得可以%name)
print(%s 同学,那你很棒啊%name)

3

1 num1 = input(请输入第一个数字:)
2 请输入第一个数字:5
3 num2 = input(请输入第二个数字:)
4 请输入第二个数字:6
5 sum = float(num1)+float(num2)
6 print(float(sum))
7 11.0

4

1 print(两数之和为 %.1f %(float(input(输入第一个数字:))+float(input(输入第二个数字:))))
2 输入第一个数字:8
3 输入第二个数字:6
4 两数之和为 14.0

5

1 a = float(input(输入三角形第一边长: ))
2 b = float(input(输入三角形第二边长: ))
3 c = float(input(输入三角形第三边长: ))
4 
5 s = (a + b + c) / 2
6 
7 area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
8 print(三角形面积为 %0.2f %area)

6

1 r = 10
2 area = 3.1415 * r * r
3 print(area)
4 print("{:.2f}".format(area))
5 
6 314.15000000000003
7 314.15

7

1 import turtle
2 turtle.pensize(3)
3 turtle.circle(10)
4 turtle.circle(30)
5 turtle.circle(60)
6 turtle.circle(90)
7 turtle.circle(120)

技术分享

8

 1 import turtle
 2 turtle.forward(100)
 3 turtle.left(144)
 4 turtle.forward(100)
 5 turtle.left(144)
 6 turtle.forward(100)
 7 turtle.left(144)
 8 turtle.forward(100)
 9 turtle.left(144)
10 turtle.forward(100)

技术分享

9

1 from turtle import *
2 fillcolor("yellow")
3 begin_fill()
4 while True:
5     forward(200)
6     right(144)
7     if abs(pos())< 1:
8         break
9 end_fill()

技术分享

10

1 for i in range(4):
2     turtle.pu()
3     turtle.goto(0,-(i+1)*10)
4     turtle.pd()
5     turtle.circle((i+1)*10)

技术分享

 

11

 1 import turtle
 2 turtle.penup()
 3 turtle.goto(-300,300)
 4 turtle.pendown()
 5 turtle.color("red")
 6 turtle.fillcolor("red")
 7 turtle.begin_fill()
 8 turtle.forward(500)
 9 turtle.right(90)
10 turtle.forward(300)
11 turtle.right(90)
12 turtle.forward(500)
13 turtle.right(90)
14 turtle.forward(300)
15 turtle.right(90)
16 turtle.end_fill()
17 turtle.penup()
18 turtle.goto(-250,250)
19 turtle.pendown()
20 turtle.color("yellow")
21 turtle.fillcolor("yellow")
22 turtle.begin_fill()
23 for i in range(5):
24     turtle.forward(150)
25     turtle.right(144)
26 turtle.end_fill()
27 turtle.penup()
28 turtle.goto(-90,280)
29 turtle.pendown()
30 turtle.begin_fill()
31 for i in range(5):
32     turtle.forward(40)
33     turtle.right(144)
34 turtle.end_fill()
35 turtle.penup()
36 turtle.goto(-80,230)
37 turtle.pendown()
38 turtle.begin_fill()
39 for i in range(5):
40     turtle.forward(40)
41     turtle.right(144)
42 turtle.end_fill()
43 turtle.penup()
44 turtle.goto(-90,190)
45 turtle.pendown()
46 turtle.begin_fill()
47 for i in range(5):
48     turtle.forward(40)
49     turtle.right(144)
50 turtle.end_fill()
51 turtle.penup()
52 turtle.goto(-95,140)
53 turtle.pendown()
54 turtle.begin_fill()
55 for i in range(5):
56     turtle.forward(40)
57     turtle.right(144)
58 turtle.end_fill()

技术分享

 

python练习9-7

标签:import   put   begin   inpu   print   技术分享   down   from   for   

原文地址:http://www.cnblogs.com/yxhjss/p/7488728.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!