




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























1.2.2 Quiz: Karel Commands Question: 1 Which of these is a valid Karel command? move MOVE move() move(1) Question: 2 Which one of these is NOT a command that Karel knows? Turn Left Turn Right Move Forward Put Down a Ball - ANSmove()
Turn Right 1.2.4: Your First Karel Program - ANSif front_is_clear(): move() if balls_present(): take_ball() else: move() if front_is_clear(): move() if balls_present(): take_ball() else: move() if balls_present(): take_ball() 1.2.5: Short Stack - ANSmove() put_ball() put_ball() move() 1.3.2 More Basic Karel Quiz Question: 1 What is a street in a Karel world?
Street 6 and Avenue 2 Question: 4 If Karel is facing North and the code turn_left() turn_left() runs, which direction is Karel facing now? North South East West - ANSA row A column Street 2 and Avenue 6 South 1.3.4: Make a Tower - ANSmove() turn_left() put_ball() move() put_ball() move() put_ball()
move() turn_left() turn_left() turn_left() 1.3.5: Pyramid of Karel - ANSput_ball() move() put_ball() move() turn_left() put_ball() move() put_ball() turn_left() move() put_ball() turn_left() turn_left() move() turn_left() move() put_ball() turn_left() turn_left() turn_left()
move() turn_left() 1.4.5: Slide Karel - ANSdef turn_right(): turn_left() turn_left() turn_left() put_ball() move() turn_right() move() put_ball() move() turn_left() move() put_ball() 1.5.2 Functions in Karel Quiz Question: 1 Which function will teach Karel how to spin in a circle one time? A def spin(): turn_right() B def spin(): turn_left()
turn_left() turn_left() turn_left() C def spin(): turn_left() turn_left() D def spin(): move() move() move() move() A B C D - ANSB 1.5.4: Pancakes - ANSdef make_pancakes(): put_ball() put_ball() put_ball() move() make_pancakes() move()
turn_right() move() move() move() put_ball() turn_around() move() move() move() turn_right() move() move() bury_ball() move() move() move() bury_ball() move() move() move() bury_ball() move() 1.6.2 Top Down Design and Decomposition Quiz Question: 1 Why do we use functions in programming?
Break down our program into smaller parts Avoid repeating code Make our program more readable All of the above Question: 2 What is top down design? Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve. Top down design is a way that you can create designs on a computer to put on a web page Top down design is a way of designing your programs starting with the individual commands first Top down design is a way to use loops and classes to decompose the problem - ANSAll of the above Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve. 1.6.4: The Two Towers - ANSdef stack(): put_ball() turn_left()
turn_right() 1.7.2 Commenting Your Code Quiz Question: 1 What is a code comment? A way to teach Karel a new word A way to give notes to the reader to explain what your code is doing A message to your teacher in code A place to write whatever you want in your code - ANSA way to give notes to the reader to explain what your code is doing 1.7.4: The Two Towers + Comments - ANSdef stack(): put_ball() turn_left() move() put_ball() move() put_ball() turn_twice() move() move() turn_left() def turn_twice(): turn_left() turn_left()
def turn_right(): turn_left() turn_left() turn_left() move()
stack() move() move() turn_left()
put_ball() move() put_ball() move() put_ball() move() turn_right() 1.8.2 Abstraction Quiz Question: 1 Each of the following answer choices describes a basketball game. Which answer choice describes the game with the lowest level of abstraction? The Warriors won by 10 points.
m - ANSFirst, Steph Curry flexed his left and right quad muscles at the exact same time, then he flexed each muscle in his fingers... move_to_pile() take_pile() 1.9.2 Super Karel Quiz Question: 1 What commands does SuperKarel know that regular Karel does not? turn_left() and jump() turn_right() and jump() turn_around() and turn_right() turn_around() and jump() - ANSturn_around() and turn_right() 1.9.4: The Two Towers + SuperKarel - ANSdef stack(): put_ball() turn_left() move() put_ball() move() put_ball() turn_around() move() move()
turn_left() move()
stack() move() move() turn_left()
put_ball() move() put_ball() move() put_ball() move() turn_right() 1.10.2 For Loops Quiz Question: 1 What is the best way for Karel to move 10 times? move() move() move() move() move() move()
1.10.8: Lots of Hurdles - ANSdef jump_hurdle(): turn_left() move() turn_right() move() turn_right() move() turn_left() for i in range(5): move() move() jump_hurdle() 1.11.2 If Statements Quiz Question: 1 Why do we use if statements in Python? To break out of some block of code To do something only if a condition is true To do something while a condition is true To repeat something for a fixed number of times Question: 2 Which general if statement definition is written correctly? A for condition: # code
if condition: # code C if i in range(COUNT): #code D if false: # code A B C D - ANSTo do something only if a condition is true B 1.11.5: Is There a Ball? - ANSif no_balls_present(): put_ball() move() 1.12.2 If/Else Statements Quiz Question: 1 What does an if/else statement look like in Python? if condition:
if condition: