wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

🌟CodeHS Unit 2 {Review Quiz}🌳

Total questions: 41

Worksheet time: 21mins

Name
Class
Date
1.

🌟Which of the following commands is a valid Karel command?

a)

move

b)

move;

c)

move();

d)

move()

2.

🌟🌟What makes the following command an invalid Karel command? turnleft();

a)

It should end in a colon rather than a semicolon

b)

The l should be a capital L

c)

It should start with a capital T

d)

This command is correct

3.

🌟Which of the following is the correct way to define a turnRight function in Karel?

a)

function turnRight() { turnLeft(); turnLeft(); turnLeft(); }

b)

function turnRight() { turnLeft(); turnLeft(); }

c)

function turnRight() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); }

d)

function turnRight() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); turnLeft(); }

4.

🌟Why do we use functions in Karel programs?

a)

Break down our program into smaller parts

b)

Avoid repeating code

c)

Make our program more readable

d)

All of the above

5.

🌟If Karel starts at Street 1 and Avenue 1, facing East, where will Karel be, and what direction will Karel be facing after running the following code? (Assume the world is 10x10 in size)

a)

Street 3, Avenue 1, Facing North

b)

Street 1, Avenue 4, Facing North

c)

Street 1, Avenue 3, Facing South

d)

Street 1, Avenue 3, Facing North

6.

🌟If Karel starts at Street 1 and Avenue 1, facing East, where will Karel be, and what direction will Karel be facing after running the following code? (Assume the world is 10x10 in size) move(); turnLeft(); putBall(); turnLeft(); turnLeft(); turnLeft(); move(); turnLeft();

a)

A) Street 2, Avenue 1, Facing West

b)

B) Street 3, Avenue 1, Facing North

c)

C) Street 1, Avenue 2, Facing South

d)

D) Street 3, Avenue 2, Facing East

7.

🌟In this code, how many times is the dance function called and how many times is it defined?🌟

a)

Called 1 time, defined 1 time

b)

Called 1 time, defined 3 times

c)

Called 3 times, defined 1 time

d)

Called 3 times, defined 3 times

8.

🌟What’s wrong with this code?

a)

The go function is called twice

b)

The go function has a syntax error

c)

The go function has been defined twice

d)

go is not a command that Karel understands

9.

🌟How many total times will Karel move in this program?

a)

1

b)

5

c)

6

d)

7

10.

🌟What is wrong with this for loop?

A. The for loop uses commas instead of semicolons

B. It should say i++ instead of i + 1

a)

A

b)

B

c)

A and B

d)

The for loop is correct

11.

🌟What is the proper format for a single line comment in Karel?

a)

This is a comment

b)

// This is a comment

c)

/* This is a comment

d)

This is a comment

12.

🌟What does the mystery function do?

a)

Karel moves until it is on a ball

b)

Karel moves once if there is no ball present

c)

Karel moves until it puts down a ball

d)

Karel checks if there is no ball on the current spot and then moves once

13.

🌟Which of the following is not a valid condition to go in an if statement for Karel?

a)

Karel moves until it is on a ball

b)

Karel moves once if there is no ball present

c)

Karel moves until it puts down a ball

d)

Karel checks if there is no ball on the current spot and then moves once

14.

I🌟Say Karel is on a location with one tennis ball. After the following code runs, how many tennis balls will there be at that location?

a)

0

b)

1

c)

2

d)

6

15.

🌟What condition should be used in this while loop to get Karel to pick up all the tennis balls on the current location?

a)

noBallsPresent()

b)

ballsPresent()

c)

frontIsClear()

d)

takeBall()

16.

🌟Why does a programmer indent their code?

a)

Helps show the structure of the code.

b)

Easier for other people to understand.

c)

A key part of good programming style!

d)

All of the above

17.

🌟How can we teach Karel new commands?

a)

For loop

b)

While loop

c)

Define a new function

d)

The start function

18.

🌟Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?

a)

If statement

b)

While loop

c)

For loop

d)

Nested while loop

19.

🌟Super Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs?

a)

Karel ends on street 1, avenue 3

b)

Karel ends on street 2, avenue 3

c)

This code won’t run because of a syntax error

d)

Karel will crash into a wall

20.

🌟Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs?

a)

Karel will end on Street 1, Avenue 2

b)

Karel will end on Street 1, Avenue 7

c)

This code won’t run because of a syntax error

d)

Karel will crash into a wall

21.

🌟What is top down design?

a)

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.

b)

Top down design is a way that you can create designs on a computer to put on a web page

c)

Top down design is a way of designing your programs starting with the individual commands first

d)

Top down design is a way to use loops and if statements to decompose the problem

22.

🌟🌟How can we improve the following program?

a)

Break down this program into more functions

b)

Use a for loop to repeat the move command

c)

Use a while loop to repeat the move command

d)

Fix the indentation of this program

23.

🌟In the following code below from the Cleanup Karel example, what is the purpose of If Statement #2?

a)

To move the last time

b)

To pick up the ball that is in the last spot

c)

To pick up the ball that is in the last spot, if there is one

d)

To take the ball from all of the positions that have a ball on them

24.

🌟In the following code, what would be a good Postcondition to write?

a)

Karel is on a spot with a tennis ball facing north

b)

Karel ends one spot above a tennis ball facing East.

c)

Karel is on the same position but on top of a ball.

d)

Karel is facing East.

25.

What type of loop is used to repeat a block of code a specific number of times?

a)

For loop

b)

Nested while loop

26.

🌟What is the purpose of using a for loop in code?

a)

To do something if a condition is true

b)

To do something while a condition is true

c)

To repeat something a fixed number of times

d)

To make programs run faster.

27.

 In computer programming, what is a variable?

a)

A problem in the software

b)

A sequence of instructions

c)

An instruction that does not change

d)

 

A placeholder for a piece of information that can change

28.

In computer programming, what is an algorithm?

a)

A problem in the software

b)

A sequence of instructions

c)

A computer programming language

d)

A solution to a programming problem

29.

All programming languages:

a)

Are text-based

b)

Are block-based

c)

Share the same syntax

d)

Share coding concepts such as looping

30.

Which of the following could be TRUE for Artificial Intelligence?

I. It’s the capability of a machine to imitate intelligent human behavior.

II. It can easily be used to mimic human emotions.

III. It’s a branch of computer science dealing with the simulation of intelligent behaviors in computers.

IV. It can be easily used to detect irony or sarcasm in a story.

V. It can be easily used to read body language.

a)

I, II, III, IV, and V

b)

II, IV, and V

c)

I and III

d)

I, II, III, and IV

31.

Which college degree has an average starting salary higher than computer science?

a)

Social Work

b)

Education

c)

Business

d)

Engineering

32.

Which of the following best explains what happens when a new device is connected to the Internet?

a)

A device driver is assigned to the device.

b)

An Internet Protocol (IP) address is assigned to the device.

c)

A packet number is assigned to the device.

d)

A Web site is assigned to the device.

33.

Which of the following is not a main method for sending information from one computer to another?

a)

Electricity

b)

Light

c)

Molecules

d)

Radio

34.

Fiber optic cables transfer data at the speed of light, so they have the _______________ latency. This results in the __________ connection.

a)

lowest, slowest

b)

lowest, fastest

c)

highest, slowest

d)

highest, fastest

35.

Which of the following is considered an unethical use of computer resources?

a)

Downloading file sharing software on your home computer.

b)

Searching online for the answers to CodeHS exercises and quizzes.

c)

Purchasing an app from an app store and downloading it directly to a mobile device.

d)

Searching online for an electronic version of a textbook.

36.

Which of the following best describes the basic purpose of the internet?

a)

The internet protects the privacy of sensitive information.

b)

The internet sends information from one computer to another.

c)

The internet stores data.

d)

The internet connects input and output devices to a computer.

37.

Consider this network diagram:


Each box represents a device connected to the network, each line represents a direct connection between two devices.

Which of the following statements are true about this network:

  • - The network is fault tolerant. If one connection fails, any two devices can still communicate.

  • - Computers C and E need to first communicate with at least one other device in order to communicate with each other.

a)

I only

b)

II only

c)

I and II

d)

Neither I nor II

38.

True or False: As long as you cite your source, it is legal to use or share any kind of media you find on the Internet.

a)

True

b)

False

39.

Who created the first "robot" and when did it happen?

a)

Archytas of Tarentum, ~400 BCE

b)

Yah Shi, 3rd Century BCE

c)

 

Ismail al-Jazari, 1206

d)

Jacques de Vaucanson, 1738

e)

Nikola Tesla, 1898

40.

ARPANET was built to help people do things like:

a)

Move troops around the country

b)

Sort through census data

c)

Track the movement of distant galaxies

d)

Connect with friends all over the world

41.

Which of the following people can access your digital footprint?

I. Teachers, colleges, and scholarship committees
II. Potential employers
III. Family, friends, and acquaintances

a)

I only

b)

I and II only

c)

III only

d)

I-III All