6.19+Chapter+3+Doris

Chapter 3 1. code n=1000 for i in range(n): print('We like Python’s turtles! ') code 3. code format="python" for i in ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']: print('One of the months of the year is',i)

code 5. code xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] for i in range(9): print(xs[i],end=' ') for i in range(9): print(xs[i]**2,end=' ') total = 0 for i in range(0, 9): total = total + xs[i] print(total, end=' ') for i in range(0,9): product = product * xs[i] print(product)

code 6. code n=3 import turtle wn=turtle.Screen for i in range(n): turtle.forward(100) turtle.left(360/n) wn.mainloop code 7,8 code format="python" import turtle wn=turtle.Screen for i in[160, -43, 270, -97, -43, 200, -940, 17, -86]: alex.left(i) alex.forward(60) wn.mainloop code 11. code format="python" import turtle wn＝turtle.Screen turtle.hideturtle for i in range (5): turtle.forward(100) turtle.right(180-36) wn.mainloop code 12. code format="python" import turtle wn=turtle.Screen turtle.shape('turtle') turtle.stamp for i in range(12): turtle.penup turtle.forward(50) turtle.pendown turtle.forward(5) turtle.penup turtle.forward(15) turtle.stamp turtle.goto(0,0) turtle.right(30) wn.mainloop code 13. code format="python" import turtle a=turtle.Turtle print(type(a))

code