Docsity

CodeHS: Introduction to Programming (Python) Exam | Questions with Correct Answers | 100%, Exams of Computer Science

Toggle sidebar
bg1
CodeHS: Introduction to Programming (Python) Exam | Questions
with Correct Answers | 100% Pass
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():
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download CodeHS: Introduction to Programming (Python) Exam | Questions with Correct Answers | 100% and more Exams Computer Science in PDF only on Docsity!

CodeHS: Introduction to Programming (Python) Exam | Questions

with Correct Answers | 100% Pass

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

A column

A single point

Karel's position

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

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?

Question: 2

What can be used to teach Karel to turn right?

Functions

Variables

Dog treats

Karel can already turn right - ✔✔ 3

Functions

1.4.4: Fireman Karel - ✔✔def turn_right():

turn_left() turn_left()

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 - ✔✔B

1.5.4: Pancakes - ✔✔def make_pancakes():

put_ball() put_ball() put_ball()

move()

make_pancakes()

move()

move()

make_pancakes()

move()

move()

make_pancakes()

move()

1.5.5: Backflip - ✔✔def backflip():

turn_left() turn_left() turn_left() turn_left()

move()

move()

move()

move()

backflip()

1.5.6: Digging Karel - ✔✔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()

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 - ✔✔All 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 - ✔✔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 explain what your code is doing

A message to your teacher in code

A place to write whatever you want in your code - ✔✔A way to give notes to the reader to explain what your code is doing

1.7.4: The Two Towers + Comments - ✔✔def stack():

put_ball() turn_left() move() put_ball() move()

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.

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

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

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() - ✔✔turn_around() and turn_right()

1.9.4: The Two Towers + SuperKarel - ✔✔def stack():

put_ball() turn_left() move() put_ball() move() put_ball() turn_around() move() move() turn_left()

move()

make a stack of 3 balls

stack()

move()

move(10)

move10() - ✔✔for i in range(10):

move()

1.10.5: Take 'em All - ✔✔move()

for i in range(100):

take_ball()

move()

1.10.6: Dizzy Karel - ✔✔for i in range(32):

turn_left()

1.10.7: For Loop Square - ✔✔for i in range(4):

put_ball() move() turn_left()

1.10.8: Lots of Hurdles - ✔✔def 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

B

if condition: # code

C

if i in range(COUNT): #code

D

if false: # code

A

B

C

D - ✔✔To do something only if a condition is true

B

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 - ✔✔if condition:

code

else:

code

To do something if a condition is true and do something else if the condition is false

1.12.5: Right Side Up - ✔✔if facing_south():

turn_left()

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

1.13.6: Big Tower - ✔✔put_ball()

if facing_west():

turn_right()

if facing_south():

turn_left() turn_left()

if facing_east():