wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

IDT Unit 2 Review (practice for Test 2)

Total questions: 20

Worksheet time: 14mins

Name
Class
Date
1.

What line of code outputs the integer portion of a decimal value stored in x?

a)

print (int(x))

b)

print (x - int(x))

c)

print(x)

d)

print(x % 10)

2.

When would you NOT use a string command? Select all that apply.

a)

To store values that are used for calculations

b)

To store a decimal number

c)

To store a word

d)

To store a list of color names

3.

Consider the code:

x = int(input("Enter a number: ")

print(x)

What happens if the user enters the letter C?

a)

error. Integer variable cannot store a string

b)

error. int and input functions cannot be written on the same line

c)

C

d)

67

4.

Which of these are standard data types in Python? Select all that apply.

a)

String

b)

int

c)

decimal

d)

random

5.

Which of these numbers might be output by this code?

print(random.randint(-5, 5))

Select all that apply.

a)

0

b)

-5

c)

10

d)

-0.5

6.

Which of these are built-in functions of Python? Select all that apply.

a)

int()

b)

sqrt()

c)

fabs()

d)

string()

7.

What is output by this code?

x = 4

y = 3

print (x ** y)

a)

64

b)

12

c)

43

d)

81

8.

What is output by this code?

x = 3.14159

print (x - int(x))

a)

0.14159

b)

3.14159

c)

0

d)

x - int(x)

9.

What is 24 % 10 ?

a)

4

b)

14

c)

2

d)

2.4

10.

What is output?

a = 5

b = - 6

c = 2

print (a + b / c)

a)

2

b)

-0.5

c)

5.5

d)

-2

11.

What function would you use to find the absolute value of a number?

a)

fabs(num)

b)

sqrt(num)

c)

seed(num)

d)

print(num)

12.

What is output by the program?

x = 6

x = x + 10

print (x)

a)

16

b)

6

c)

10

d)

610

13.

What is wrong with the program?

a)

There are multiple syntax errors on line 3.

b)

The int variables cannot be converted to Strings in the print statement.

c)

Nothing. The program will execute without errors.

d)

There is no num2 variable defined in the program.

14.

How would you add three numbers and then divide by 3 to calculate the average?

a)

(a + b + c) / 3

b)

num1 + num2 + num3

c)

x + y + z / 3

d)

x * y * z % 3

15.

What is output?

num = 9

print ("Answer: " + num + 7)

a)

error. Cannot concatenate str and int

b)

Answer: 16

c)

Answer: 97

d)

Answer: num + 7

16.

Which expressions calculate to equal 11? Select all that apply.

a)

11 % (5 + 10)

b)

6 + 7 - 2

c)

(9 - 4) * 2 + 2

d)

14 // 3 + 7 * 2

17.

Which of these is the best variable name to keep track of your score in a game?

a)

playerScore

b)

100score

c)

S

d)

xPoint

18.

What is output?

nums = [8, -4, 2, -6, 10, -12, 2, 6, -2, 4]

print (max(nums))

a)

10

b)

-12

c)

14

d)

error. max function incompatible with type 'int'

19.

What is output?

names = ["Bruce", "Ali", "Jo", "Bob", Carter", "Dan", "Ida"]

print (min(names))

a)

Ali

b)

Bruce

c)

Ida

d)

Jo

20.

Why are computers necessary for big data applications?

a)

Computers are much faster and more accurate than humans at processing large data sets

b)

Computers use expensive hardware that humans currently cannot use

c)

The values stored in big data tables cannot be changed

d)

Computers are machines that are capable to thinking for themselves and do not need to be programmed by people