File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ This code will draw a symbol depending on the rating given. A red x mark will
3+ be drawn if the rating is less than or equal to 4, a yellow line will be drawn
4+ if the rating is in between 5 including 5 and 7 including 7. Else, a check will be
5+ drawn
6+ """
7+ speed (0 )
8+ penup ()
9+ pensize (10 )
10+ rating = int (input ("Rating? (1-10): " ))
11+ def draw_x (): ## draws a red "x"
12+ left (45 )
13+ color ("red" )
14+ pendown ()
15+ for i in range (4 ):
16+ forward (40 )
17+ backward (40 )
18+ left (90 )
19+ def draw_line (): ## draws a yellow line
20+ pendown ()
21+ color ("yellow" )
22+ backward (30 )
23+ forward (60 )
24+ def draw_check (): ## draws a green check
25+ right (45 )
26+ backward (30 )
27+ pendown ()
28+ color ("green" )
29+ forward (30 )
30+ left (90 )
31+ forward (60 )
32+ ## check the rating to determine what symbol to draw
33+ if rating <= 4 :
34+ draw_x ()
35+ elif rating >= 5 and rating <= 7 :
36+ draw_line ()
37+ else :
38+ draw_check ()
Original file line number Diff line number Diff line change 1+ speed (0 )
2+ secret_number = 5
3+ def draw_check (): ##Draws the green check mark
4+ right (45 )
5+ color ("green" )
6+ pensize (10 )
7+ backward (50 )
8+ forward (50 )
9+ left (90 )
10+ forward (100 )
11+ while int (input ("Give a number (1-10): " )) != secret_number : ## Do not save the input as user_input. codehs crashed
12+ print ("Try again" )
13+ draw_check ()
Original file line number Diff line number Diff line change 1+ speed (0 )
2+ secret_number = 5
3+ user_input = int (input ("Give a number (1-10): " ))
4+ def draw_check (): ##Draws the green check mark
5+ right (45 )
6+ color ("green" )
7+ pensize (10 )
8+ backward (50 )
9+ forward (50 )
10+ left (90 )
11+ forward (100 )
12+ while user_input != secret_number : ## Do not save the input as user_input. codehs crashed
13+ if user_input < secret_number : ## CodeHS compiler broke.
14+ print ("guess higher!" )
15+ else :
16+ print ("guess lower!" )
17+ draw_check ()
Original file line number Diff line number Diff line change 1+ speed (0 )
2+ radius = 25
3+ count = 1
4+ row_value = int (input ("How many circles (1-8) would you like on the bottom? " ))
5+ x_value = - ((row_value * (radius * 2 ))/ 2 )+ 25
6+ y_value = - 225 + (count * radius )
7+ def moveup ():
8+ setposition (x_value ,y_value )
9+ penup ()
10+ moveup ()
11+ def draw_row ():
12+ for i in range (row_value ):
13+ pendown ()
14+ circle (radius )
15+ penup ()
16+ forward (radius * 2 )
17+ for i in range (row_value ):
18+ draw_row ()
19+ count = count + 1
20+ y_value = - 225 + ((count * radius )* 2 )- 25
21+ x_value = - ((row_value * (radius * 2 ))/ 2 )+ 50
22+ moveup ()
23+ row_value = row_value - 1
You can’t perform that action at this time.
0 commit comments