Download CodeHS Introduction to Programming Assignments (Python) latest updated exam with complete and more Exams Biology in PDF only on Docsity!
CodeHS: Introduction to Programming Assignments (Python) latest updated exam with complete solutions 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 | move() Turn Right 1.2.4: Your First Karel Program | if 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 | move() | put_ball() | put_ball() | move() 1.3.2 More Basic Karel Quiz Question: 1 What is a street in a Karel world? A row A column A single point Karel's position Question: 2 What is an avenue in a Karel world? A row Acolumn Street 2 and Avenue 6 South 1.3.4: Make a Tower move() turn_left() put_ball() move() | put_ball() move() put_ball() move() turn_left() | turn_left() turn_left() 1.3.5: Pyramid of Karel | put_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() What can be used to teach Karel to turn right? Functions Variables Dog treats put_ball() turn_left() turn_left() turn_left() 1.4.2 Karel Can't Turn Right Quiz Question: 1 How many times should Karel turn left in order to turn right? i | 2 : 3 13 4 | Functions Question: 2 Karel can already turn right 1.4.4: Fireman Karel def turn_rightQ): turn_left() turn_left() turn_left() turn_right() move() move() turn_left() turn_left() C def spin(): turn_left() turn_left() D def spin(): move() move() move() move() A B C D 1.5.4: Pancakes | def make_pancakes(): | put_ball() | put_ball() | put_ball() | move() | make_pancakes() | move() | move() j make_pancakes() | move() move() make_pancakes() move() | def backflip): turn_left() | turn_left() | turn_left() 1.5.5: Backflip : | move() | move() | move() | backflip() 1.5.6: Digging Karel j def turn_right(): | turn_left() | turn_left() turn_left() | def turn_around(): | turn_left() turn_left() | def bury_ball(): | turn_right() move() | move() | move() put_ball() 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 1.6.4: The Two Towers | def 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.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 A way to give notes to the reader to explain what your code is doing explain what your code is doing A message to your teacher in code A place to write whatever you want in your code 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. The Warriors had an early lead, but were down by 4 at halftime. They tied it up in the 4th quarter and the game went into overtime. They won by 10 points in overtime. First, Steph Curry jumped in the air and grabbed the ball. Then he dribbled it three times and passed it to Klay Thompson... First, Steph Curry flexed his left and right quad muscles at the exact same time, then he flexed each muscle in his fingers... Question: 2 Karel needs to pick up a pile of tennis balls. First, 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() Which of the following program functions solves the problem at the highest level of abstraction? move() move() turn_left() turn_left() turn_left() move() take_ball() take_ball() move_twice() turn_left() turn_left() turn_left() move() take_pile() move_twice() turn_right() move() take_pile() move_to_pile() take_pile() 1.9.2 Super Karel Quiz Question: 1 What commands does SuperKarel know that regular Karel does not? turn_around() and turn_right() 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() | for i in range(10): move() | move() move() move() move() move() for i in range(10): move() move(10) move10() move() for i in range(100): 1.10.5: Take 'em All H : take_ball() move() 1.10.6: Dizzy Karel for i in range(32): turn_left() for i in range(4): put_ball() 1.10.7: For Loop Square ! + move() turn_left() | def jump_hurdle(): | turn_left() | move() | turn_right() | move() 1.10.8: Lots of Hurdles turn_righto move() | turn_left() | for i in range(5): | move() | move() jump_hurdle() 1.11.2 If Statements Quiz To do something only if a condition is Question: 1 true Why do we use if statements in B 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 # code else condition: # code if condition: # code if condition: # code if condition: # code else: # code Question: 2 Why do we use if/else statements in Python? To repeat something for a fixed number of times To do something if a condition is true and do something else if the condition is false To break out of some block of code To repeat something while a condition is true 1.12.5: Right Side Up | if facing_south(): | turn_left() i if facing_west(): | turn_left() | turn_left() 1.13.2 While Loops in Karel Quiz Question: 1 Why do we use while loops in Python? To break out of some block of code To do something if a condition is true | To repeat some code while a condition is true To repeat something for a fixed number of times Question: 2 Which general while loop definition is written correctly? while x is true: # code if i<5: #code while | in range(5): # code while condition: # code | To repeat some code while a : condition is true ! while condition: # code 1.13.4: Follow The Yellow Ball Road | while balls_present(): | move() 1.13.5: Lay Row of Tennis Balls put_ball() while balls_present(): move() put_ball()