辅导python 图形界面、 python GUI 开发辅导

- 首页 >> Python编程

1 Define the drawsquare function and draw the image shown below. Assume each side is 40 pixels. (Hint: notice that the turtle has already moved away from the ending point of the last square when the program ends.)

2 Write a function drawPoly(somesides, somesize) which makes a turtle draw a regular polygon. When called with drawPoly(8, 50), it will draw a shape like this:

3 The two spirals in this picture differ only by the turn angle. Draw both.


4 Write a function sumTo(n) that returns the sum of all integer numbers up to and including n. So sumTo(10) would be 1+2+3...+10 which would return the value 55. Use the equation (n * (n + 1)) / 2.


5 Write a function to draw a five pointed star, where the length of each side is 100 units. Use the function you defined to draw five stars, but between each, pick up the pen, move forward by 350 units, turn right by 144, put the pen down, and draw the next star. You’ll get something like this (note that you will need to move to the left before drawing your first star in order to fit everything in the window):


站长地图