Karel in Python: Introduction to Python Programming - Unit 2 Question and answers already, Exams of Programming Paradigms

Karel in Python: Introduction to Python Programming - Unit 2 Question and answers already passed 2025/2026

Typology: Exams

2025/2026

Available from 01/19/2026

mad-grades
mad-grades 🇺🇸

3.7

(3)

9.2K documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Karel in Python: Introduction to
Python Programming - Unit 2 Question
and answers already passed
2025/2026
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()
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Karel in Python: Introduction to Python Programming - Unit 2 Question and answers already and more Exams Programming Paradigms in PDF only on Docsity!

Karel in Python: Introduction to

Python Programming - Unit 2 Question

and answers already passed

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()

Makes the diagonal for the 'Z'

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

using a for loop.

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

Your code should work correctly in each world

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()

This function builds a tower all the way to the top of the world.

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

front is clear, or jumping a hurdle if it is blocked.

This function has karel jump a hurdle and end up on the other side.

Precondition: Karel is facing east in front of a hurdle (one wall high)

Postcondition: Karel is facing east on the other side of the hurdle

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'])