[go: up one dir, main page]

0% found this document useful (0 votes)
28 views2 pages

Code in Place

This document provides starter code for a programming exercise involving Karel the robot. The code includes functions to make Karel climb diagonally and place beepers in a zigzag pattern. Users are encouraged to edit and run the code to solve the problem, with a solution button available for reference if needed.

Uploaded by

Shahzaib Attari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Code in Place

This document provides starter code for a programming exercise involving Karel the robot. The code includes functions to make Karel climb diagonally and place beepers in a zigzag pattern. Users are encouraged to edit and run the code to solve the problem, with a solution button available for reference if needed.

Uploaded by

Shahzaib Attari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

"""

This is a worked example. This code is starter code; you should edit and run it to
solve the problem. You can click the blue show solution button on the left to see
the answer if you get too stuck or want to check your work!
"""

from karel.stanfordkarel import *

def main():
put_beeper()
while front_is_clear():
climb_diagonal()
put_beeper()
climb_down()
put_beeper()

def climb_diagonal():
turn_left()
move()
turn_right()
move()

def turn_right():
for i in range(3):
turn_left()

def climb_down():
turn_right()
move()
turn_left()
if front_is_clear():
move()

"""
Places beepers in a zig zag pattern.
"""

pass # Delete this line and write your code here! :)


# There is no need to edit code beyond this point

if __name__ == '__main__':
main()

You might also like