Calvin (Deutschbein)
W1D2: 28 Aug
Command | Action |
---|---|
move() |
Moves Karel forward one intersection in whatever direction they are facing |
turn_left() |
Rotates Karel 90 deg counter-clockwise |
pick_beeper() |
Picks up a beeper on the ground |
put_beeper() |
Places a beeper on the ground |
|
move()
turn_left()
turn_left()
turn_left()
move()
turn_left()
move()
turn_left()
turn_left()
turn_left()
move()
pick_beeper()
turn_left()
turn_left()
turn_left()
move()
move()
put_beeper()
Okay... that was fun. Now where do I run this code?
Microsoft Windows [Version 10.0.19045.4780]
(c) Microsoft Corporation. All rights reserved.
C:\Users\cd-desk>
|
import karel
def main():
move()
move()
turn_left()
turn_left()
turn_left()
move()
turn_left()
move()
turn_left()
turn_left()
turn_left()
move()
pick_beeper()
turn_left()
turn_left()
turn_left()
move()
move()
put_beeper()
import karel
import karel
def main():
Every C program has a primary function that must be named main. The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program.
def main():
turn_left()
def reverse():
turn_left()
turn_left()