|
1 | | -#Import the turtle drawing library |
| 1 | +# Import the turtle drawing library |
2 | 2 | import turtle |
3 | 3 |
|
4 | | -#Declare variables to hold the information the user enters and set the variables to initial values |
| 4 | +# Declare variables to hold the information the user enters and set the variables to initial values |
5 | 5 | penColor = 'black' |
6 | 6 | lineLength = 0 |
7 | 7 | angle = 0 |
8 | 8 |
|
9 | | -#Ask user for values for pen color, line length, and angle |
10 | | -#Don't forget to convert the numeric values to integers! |
11 | | -lineLength = int(input("How long would you like to make the line? (specify 0 to stop drawing) " )) |
| 9 | +# Ask user for values for pen color, line length, and angle |
| 10 | +# Don't forget to convert the numeric values to integers! |
| 11 | +lineLength = int(input("How long would you like to make the line? (specify 0 to stop drawing) ")) |
12 | 12 | penColor = input("What pen color would you like to use? (black, blue, red, green): ") |
13 | 13 | angle = int(input("What angle would you like? (0-360): ")) |
14 | 14 |
|
15 | | -while lineLength != 0 : |
16 | | - #Draw a line using the values entered by the user |
| 15 | +while lineLength != 0: |
| 16 | + # Draw a line using the values entered by the user |
17 | 17 | turtle.color(penColor) |
18 | 18 | turtle.right(angle) |
19 | 19 | turtle.forward(lineLength) |
20 | | - |
21 | | - #Don't forget to ask for new values inside the loop, otherwise lineLength will never change |
22 | | - #And your loop could execute forever, like mine did the first time I wrote this code! |
23 | | - #Luckily if yo udo accidentally code an infinite loop you can just click the Stop Debugging button in Visual Studio |
24 | | - lineLength = int(input("How long would you like to make the line? (specify 0 to stop drawing) " )) |
25 | | - #If they enter a length of zero then they want to stop drawing, so don't ask for the pen color and angle |
26 | | - if lineLength != 0 : |
| 20 | + |
| 21 | + # Don't forget to ask for new values inside the loop, otherwise lineLength will never change |
| 22 | + # And your loop could execute forever, like mine did the first time I wrote this code! |
| 23 | + # Luckily if yo udo accidentally code an infinite loop you can just click the Stop Debugging button in Visual Studio |
| 24 | + lineLength = int(input("How long would you like to make the line? (specify 0 to stop drawing) ")) |
| 25 | + # If they enter a length of zero then they want to stop drawing, so don't ask for the pen color and angle |
| 26 | + if lineLength != 0: |
27 | 27 | penColor = input("What pen color would you like to use? (black, blue, red, green): ") |
28 | 28 | angle = int(input("What angle would you like? (0-360): ")) |
29 | 29 |
|
|
0 commit comments