python練習9-7

來源:互聯網
上載者:User

標籤: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 請輸入第一個數字:53 num2 = input(‘請輸入第二個數字:‘)4 請輸入第二個數字:65 sum = float(num1)+float(num2)6 print(float(sum))7 11.0

4

1 print(‘兩數之和為 %.1f‘ %(float(input(‘輸入第一個數字:‘))+float(input(‘輸入第二個數字:‘))))2 輸入第一個數字:83 輸入第二個數字:64 兩數之和為 14.0

5

1 a = float(input(‘輸入三角形第一邊長: ‘))2 b = float(input(‘輸入三角形第二邊長: ‘))3 c = float(input(‘輸入三角形第三邊長: ‘))4 5 s = (a + b + c) / 26 7 area = (s*(s-a)*(s-b)*(s-c)) ** 0.58 print(‘三角形面積為 %0.2f‘ %area)

6

1 r = 102 area = 3.1415 * r * r3 print(area)4 print("{:.2f}".format(area))5 6 314.150000000000037 314.15

7

1 import turtle2 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         break9 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.