Font size
WorksheetsIDT Unit 2 Review (practice for Test 2)
Total questions: 20
Worksheet time: 14mins
What line of code outputs the integer portion of a decimal value stored in x?
print (int(x))
print (x - int(x))
print(x)
print(x % 10)
When would you NOT use a string command? Select all that apply.
To store values that are used for calculations
To store a decimal number
To store a word
To store a list of color names
Consider the code:
x = int(input("Enter a number: ")
print(x)
What happens if the user enters the letter C?
error. Integer variable cannot store a string
error. int and input functions cannot be written on the same line
C
67
Which of these are standard data types in Python? Select all that apply.
String
int
decimal
random
Which of these numbers might be output by this code?
print(random.randint(-5, 5))
Select all that apply.
0
-5
10
-0.5
Which of these are built-in functions of Python? Select all that apply.
int()
sqrt()
fabs()
string()
What is output by this code?
x = 4
y = 3
print (x ** y)
64
12
43
81
What is output by this code?
x = 3.14159
print (x - int(x))
0.14159
3.14159
0
x - int(x)
What is 24 % 10 ?
4
14
2
2.4
What is output?
a = 5
b = - 6
c = 2
print (a + b / c)
2
-0.5
5.5
-2
What function would you use to find the absolute value of a number?
fabs(num)
sqrt(num)
seed(num)
print(num)
What is output by the program?
x = 6
x = x + 10
print (x)
16
6
10
610
What is wrong with the program?
There are multiple syntax errors on line 3.
The int variables cannot be converted to Strings in the print statement.
Nothing. The program will execute without errors.
There is no num2 variable defined in the program.
How would you add three numbers and then divide by 3 to calculate the average?
(a + b + c) / 3
num1 + num2 + num3
x + y + z / 3
x * y * z % 3
What is output?
num = 9
print ("Answer: " + num + 7)
error. Cannot concatenate str and int
Answer: 16
Answer: 97
Answer: num + 7
Which expressions calculate to equal 11? Select all that apply.
11 % (5 + 10)
6 + 7 - 2
(9 - 4) * 2 + 2
14 // 3 + 7 * 2
Which of these is the best variable name to keep track of your score in a game?
playerScore
100score
S
xPoint
What is output?
nums = [8, -4, 2, -6, 10, -12, 2, 6, -2, 4]
print (max(nums))
10
-12
14
error. max function incompatible with type 'int'
What is output?
names = ["Bruce", "Ali", "Jo", "Bob", Carter", "Dan", "Ida"]
print (min(names))
Ali
Bruce
Ida
Jo
Why are computers necessary for big data applications?
Computers are much faster and more accurate than humans at processing large data sets
Computers use expensive hardware that humans currently cannot use
The values stored in big data tables cannot be changed
Computers are machines that are capable to thinking for themselves and do not need to be programmed by people
