I have an homework as follows:
Write a program where you enter from the keyboard a number n. Then n stars are drawn onto the screen, circling around the center of your screen. You can assume that 1 < n < 20.
The solution I came up with is below.
import turtle window=turtle.Screen() window.screensize(1200,1200) draw=turtle.Turtle() draw.pensize(2) draw.speed('fastest') angle = [36,144,144,144,144] GetNumber = int(input("Enter a number: ")) while GetNumber <= 1 or GetNumber >= 20: print("Enter a number between from 2 to 19") GetNumber = int(input("Enter a number: ")) for shape in range(GetNumber): for i in angle: draw.left(i) draw.forward(180) draw.penup() draw.forward(60) draw.pendown() draw.left(170)
Is there any way to improve this code? I think my code is OK, but I believe there are perhaps more concise or better solutions (working faster perhaps?)
Perhaps angle (currently 170) should be changed or perhaps an dynamic angle changer code can be implemented for the sake of improving the solutions. What do you think?