




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Karel in Python: Introduction to Python Programming - Unit 2 Question and answers already passed 2025/2026
Typology: Exams
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















2.1.4: Your First Karel - correct answer ✔move() move() move() move() take_ball() 2.1.5: Short Stack - correct answer ✔move() put_ball() put_ball() move() 2.1.6: Dancing Karel - correct answer ✔move() move() turn_left() turn_left() turn_left() turn_left() 2.2.4: Make a Tower - correct answer ✔def turn_right(): turn_left() turn_left()
turn_left() def build_tower(): move() turn_left() put_ball() move() put_ball() move() put_ball() move() turn_right() def drop_from_tower(): move() turn_right() move() move() move() turn_left() build_tower() drop_from_tower() turn_left() move() move()
2.2.6: Go Through the Door - correct answer ✔turn_left() move() move() turn_left() turn_left() turn_left() move() move() move() move() turn_left() turn_left() turn_left() move() turn_left() 2.3.4: Fireman Karel - correct answer ✔def turn_right(): turn_left() turn_left() turn_left() turn_right() move() move() move() turn_left()
2.3.5: Slide Karel - correct answer ✔def turn_right(): turn_left() turn_left() turn_left() put_ball() move() turn_right() move() put_ball() move() turn_left() move() put_ball() 2.4.4: Pancakes - correct answer ✔def make_pancakes(): put_ball() put_ball() put_ball() move() make_pancakes() move() move() make_pancakes() move()
move() move() move() turn_left() turn_left() turn_left() move() move() bury_ball() move() move() move() bury_ball() move() move() move() bury_ball() move() 2.4.7: Build a Shelter - correct answer ✔def turn_right(): turn_left() turn_left() turn_left() def make_side(): move()
put_ball() move() put_ball() move() put_ball() def go_home(): turn_right() move() move() move() turn_left() turn_left() turn_left() make_side() turn_right() make_side() turn_right() make_side() go_home() 2.5.4: The Two Towers - correct answer ✔def turn_right(): turn_left() turn_left() turn_left() def build_tower():
move() put_ball() move() put_ball() move() put_ball() move() put_ball()
def make_diagonal(): turn_right() move() turn_right() move() put_ball() turn_left() move() turn_right() move() put_ball() turn_left() move() turn_right() move() put_balls_in_row()
make_diagonal() move() turn_around() put_balls_in_row() 2.6.4: The Two Towers + Comments - correct answer ✔def turn_right(): turn_left() turn_left() turn_left() """ This function moves Karel one step foward before she builds a 3 ball tower and ends with Karel facing east """ def build_tower(): move() turn_left() put_ball() move() put_ball() move() put_ball() move() turn_right() """ After Karel is on a tower, this function will bring down Karel from the tower and ends with Karel facing east
turn_right() def drop_from_tower(): move() turn_right() move() move() move() turn_left() build_tower() drop_from_tower() build_tower() 2.9.5: Take 'em All - correct answer ✔move() for i in range(100): take_ball() move() 2.9.6: Dizzy Karel - correct answer ✔for i in range(32): turn_left() 2.9.7: For Loop Square - correct answer ✔# Try to lay down a square of four tennis balls
def turn_right(): turn_left()
turn_left() turn_left() turn_right() for i in range(4): turn_left() put_ball() move() turn_left() 2.9.8: Lots of Hurdles - correct answer ✔def run_to_hurdle(): move() move() def jump_hurdle(): turn_left() move() turn_right() move() turn_right() move() turn_left() for i in range(5): run_to_hurdle() jump_hurdle() 2.10.5: Is There a Ball? - correct answer ✔# Use the dropdown in the editor to change worlds
put_ball() 2.12.6: Big Tower - correct answer ✔# This program draws a big tower from Karel's starting spot while not_facing_north(): turn_left() while front_is_clear(): put_ball() move() put_ball() 2.13.4: Random Hurdles - correct answer ✔def jump_hurdle(): turn_left() move() turn_right() move() turn_right() move() turn_left() for i in range(13): if front_is_clear(): move() else: jump_hurdle() 2.14.3: Debug: The Two Towers - correct answer ✔def turn_right():
turn_left() turn_left() turn_left() def turn_around(): turn_left() turn_left() def come_down(): turn_around() move() move() turn_left() def build_tower(): turn_left() put_ball() move() put_ball() move() put_ball() move() build_tower() come_down() move() move() build_tower() move()
def build_tower(): while front_is_clear(): put_ball() move() turn_north() build_tower() put_ball() 2.14.8: Debug: Random Hurdles - correct answer ✔# This function has karel move across a world of 14 columns, moving if the
def turn_right(): turn_left() turn_left() turn_left() def jump_hurdle(): turn_left() move() turn_right() move() turn_right() move()
turn_left() for i in range(13): if front_is_blocked(): jump_hurdle() else: move() 2.15.6: Decorate the Fence - correct answer ✔while front_is_clear(): move() turn_left() for i in range(9): if right_is_blocked(): put_ball() move() else: move() while not_facing_north(): turn_left() put_ball() 2.16.5: Invert Colors - correct answer ✔""" This program has Karel invert colors """ for i in range(9): if color_is(color['red']): paint(color['blue'])