Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TechSmart Unit 2 Test

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

What is the name of the data type that can only be True or False?

a)

integer

b)

string

c)

y/n

d)

boolean

2.

Which of the following is a boolean expression?

a)

x + 1

b)

x = 100

c)

x == y

d)

12 * 5

3.

How many times does the following loop repeat?

a)

never

b)

1 time

c)

90 times

d)

infinitely

4.

In the following code, what print statements will be printed?

a)

print("x and y are equal")

b)

print("x is less than 100")

c)

print("y is less than 100")

d)

print("Something else.")

5.

In the following code, select all the print statement that will be printed.

a)

print("x and y are equal")

b)

print("x is less than 100")

c)

print ("y is less than 100")

d)

print("Something else.")

6.

In the following code, select all print statement that will be printed.

a)

print("x and y are equal")

b)

print("x is less than 100")

c)

print("Something else.")

d)

print("y is less than 100")

7.

How many times will the following code print the statement "Print me"?

(a)  

8.

Will the following boolean expression return True or False?

a)

True

b)

False

9.

Will the following boolean expression return True or False?

a)

True

b)

False

10.

Will the following boolean expression return True or False?

a)

True

b)

False

11.

Will the following boolean expression return True or False?

a)

True

b)

False

12.

What's wrong with the following loop?

a)

It won't loop even once

b)

Input can't be inside a loop

c)

Input gets a string, so x < 100 is not a valid condition

d)

The == operator is used to store input, not =

13.

In the following code, select the conditional that includes elif-clauses.

a)

Lines 4 & 5

b)

Lines 7 & 8

c)

Lines 10 & 11

d)

Lines 13 & 14

e)

Lines 16 & 17

14.

Select the conditions in the following code.

a)

x == y

b)

x < 100

c)

x > 100

d)

else

15.

What is the name of the library used in this code?

(a)  

16.

What type of error prevents your code from running?

a)

Syntax error

b)

Runtime error

c)

Logic error

d)

You can always run code, even when you have errors

17.

In the code below, select the line that will cause a runtime error.

a)

Line 2

b)

Line 3

c)

Line 4

d)

Line 5

18.

What symbol is used to separate multiple arguments within a function call?

a)

) (parenthesis)

b)

. (dot)

c)

, (comma)

d)

# (number sign)

19.

What is the highest number of times this loop could repeat?

(a)  

20.

What is one use for the dot operator in Python?

a)

Separate the arguments in a function call

b)

Designate the end of a code statement

c)

Call a function from a library

d)

Replace a space in a variable name

21.

Change one symbol in this code so it loops 20 times instead of infinitely. (It should still print multiples of 5.)

a)

-= to !=

b)

-= to +=

c)

-= to ==

d)

-= to %

22.

What two arguments does the random.randint function require?

a)

random and randint

b)

A minimum and a maximum

c)

( and )

d)

, and .

23.

What strategy can be used to find logic errors?

a)

Look at the error message

b)

Insert print statements

c)

Either error messages or print statements

d)

Logic errors cannot be found by a person

24.

What strategy can be used to find runtime errors?

a)

Look at the error message

b)

Insert print statements

c)

Either error messages or print statements

d)

Runtime errors cannot be found by a person

25.

What strategy can be used to find syntax errors?

a)

Look at the error message

b)

Insert print statements

c)

Either error messages or print statements

d)

Syntax errors cannot be found by a person