Feb-28-2019, 08:43 AM
The following is an exercise question from tutorial course and my code.
Write a program that asks the user for the number of sides, the length of the side, the color, and the fill color of a regular polygon. The program should draw the polygon and then fill it in.
Input pop-ups work, but otherwise, no output.
Write a program that asks the user for the number of sides, the length of the side, the color, and the fill color of a regular polygon. The program should draw the polygon and then fill it in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import turtle wn = turtle.Screen() alex = turtle.Turtle() sides = input ( "Number of sides in polygon?" ) length = input ( "Length of the sides in polygon?" ) colorname = input ( "Color of polygon?" ) fcolor = input ( "Fill color of polygon?" ) alex.color = (colorname) alex.fillcolor = (fcolor) for i in range (sides): alex.forward (length) alex.left ( 360 / sides) |