1 #!/usr/bin/env Python32 #-*-coding:utf-8-*-3 4 #01 Temperature Conversion5 whileTrue:6val = input ("Please enter a temperature value (e.g. 32C) with temperature indication symbol:")7 ifVAL[-1]inch['C','C']:8f = 1.8 * Float (val[0:-1]) + 329 Print("the converted temperature is:%.2ff"%f)Ten Break One elifVAL[-1]inch['F','F']: Ac = (float (val[0:-1])-32)/1.8 - Print("the converted temperature is:%.2FC"%c) - Break the Else: - Print("wrong input") - Continue - + #02 Python Small program - fromTurtleImport* + ImportTurtle A defDrawsnake (rad, Angle, Len, Neckrad): at forIinchRange (len): - turtle.circle (rad, Angle) -Turtle.circle (-rad, Angle) -Turtle.circle (Rad, ANGLE/2) - TURTLE.FD (RAD) -Turtle.circle (neckrad+1, 180) inTURTLE.FD (RAD*2/3) - to defMain (): +Turtle.setup (1360,768, 0,0) -Pythonsize = 10 the turtle.pensize (pythonsize) *Turtle.pencolor ("#3B9909") $Turtle.seth (-40)Panax NotoginsengDrawsnake (40,80,5,PYTHONSIZE/2) - Done () the + Main () A the #03 Use the TURTLE.FD () function and the Turtle.seth () function in the Turtle Library to draw a equilateral triangle + ImportTurtle - $ defMain (): $Turtle.setup (1360,768, 0,0) -Pythonsize = 1 - turtle.pensize (pythonsize) theTurtle.pencolor ("#3B9909") - turtle.seth (0)WuyiTURTLE.FD (80) theTurtle.seth (120) -TURTLE.FD (80) WuTurtle.seth (-120) -TURTLE.FD (80) About Turtle.done () $ -Main ()
Python Learning---The second week of homework