-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday_06.py
More file actions
138 lines (115 loc) · 2.57 KB
/
day_06.py
File metadata and controls
138 lines (115 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
### reeborg practice - use reeborg.ca for all the practice exercises
### chose Python as a language.
## Loops
## for item in list_of_items:
## do something to each item
## for number in range(a, b):
## print(number)
## while something_is_true:
# do something repeatedly
## making a function
# # defining a function -> def name ()
# def test_function():
# print("Test")
# print("Learn")
# # call the function or accessing the function
# test_function()
# def turn_around():
# turn_left()
# turn_left()
# move()
# move()
# turn_around()
# move()
# move()
# turn_around()
# # # EXERCISE NO. 1 - turning draw a square
# def turn_right():
# turn_left()
# turn_left()
# turn_left()
# turn_left()
# move()
# move()
# turn_right()
# move()
# move()
# turn_right()
# move()
# move()
# turn_right()
# move()
# move()
# # # EXERCISE NO. 2 - hurdle 1 - def function
# def robot_jump():
# move()
# turn_left()
# move()
# turn_left()
# turn_left()
# turn_left()
# move()
# turn_left()
# turn_left()
# turn_left()
# move()
# turn_left()
# use the for xxx in range(AA) to repeat the function need for AA times
# for robot in range(6):
# robot_jump()
# # using while loop to do the same
# number_of_hurdles = 6
# # while number_of_hurdles > 0:
# robot_jump()
# number_of_hurdles -= 1
# # # EXERCISE NO. 3 - variable position Hurdles
# def turn_right():
# turn_left()
# turn_left()
# turn_left()
# def jump():
# turn_left()
# move()
# turn_right()
# move()
# turn_right()
# move()
# turn_left()
# while not at_goal():
# if wall_in_front():
# jump()
# else:
# move()
# # # EXERCISE NO. 4 - Random height hurdle with random goal
# def turn_right():
# turn_left()
# turn_left()
# turn_left()
# def jump():
# turn_left()
# while wall_on_right():
# move()
# turn_right()
# move()
# turn_right()
# while front_is_clear():
# move()
# turn_left()
# while not at_goal():
# if wall_in_front():
# jump()
# else:
# move()
# # # EXERCISE NO. 5 - Reeborg Maze - infinite loop if the right side is empty
# def turn_right():
# turn_left()
# turn_left()
# turn_left()
# while not at_goal():
# if right_is_clear():
# turn_right()
# move()
# elif front_is_clear():
# move()
# else:
# turn_left()