-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectNewspaperKarel.py
More file actions
53 lines (37 loc) · 925 Bytes
/
CollectNewspaperKarel.py
File metadata and controls
53 lines (37 loc) · 925 Bytes
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
from karel.stanfordkarel import *
"""
File: CollectNewspaperKarel.py
------------------------------
At present, the CollectNewspaperKarel file does nothing.
Your job in the assignment is to add the necessary code to
instruct Karel to walk to the door of its house, pick up the
newspaper (represented by a beeper, of course), and then return
to its initial position in the upper left corner of the house.
"""
def main():
go_outside()
pick_beeper()
go_back()
def go_outside():
move()
move()
turn_right()
move()
turn_left()
move()
def turn_right():
for i in range(3):
turn_left()
def go_back():
turn_around()
while front_is_clear():
move()
turn_right()
move()
turn_right()
def turn_around():
for i in range(2):
turn_left()
# There is no need to edit code beyond this point
if __name__ == "__main__":
run_karel_program()