Unit 1: Introduction; Variables, Expressions and Statements - Practice Quiz
1 What is the primary purpose of a programming language?
2 Python is best described as which type of programming language?
3 Who is credited with creating the Python programming language?
4 Which type of error occurs when Python code violates the rules of the language, such as a missing colon?
5 What is the process of finding and fixing errors in a program called?
6 Which of the following is a valid Python identifier?
7 Which statement about Python identifiers is true?
8 What is a variable in Python?
9
What does the statement x = 5 do in Python?
10 Which of the following is an example of an expression in Python?
11 By convention, how are named constants usually written in Python?
12
What will be the values of a and b after a, b = 1, 2?
13
Which single statement correctly swaps the values of x and y in Python?
14 Which of the following are the two Boolean values in Python?
15 Which numeric data type represents whole numbers in Python?
16
What is the data type of the value 3.14 in Python?
17 Which operator is used for exponentiation in Python?
18
What is the result of the expression 2 + 3 * 4 in Python?
19
What does the statement x += 3 mean in Python?
20
What does the function int(4.9) return in Python?
21
What is the data type of the result of the expression 7 / 2 in Python 3?
22
What is the output of 17 % 5 in Python?
23
What is the value of the expression 2 + 3 * 4 ** 2?
24
What does the expression 2 ** 3 ** 2 evaluate to in Python?
25
After the code x = 10 followed by x //= 3, what is the value of x?
26
After executing a, b = 5, 10 and then a, b = b, a, what are the values of a and b?
27
What is the output of int(9.99) in Python?
28
What does round(2.5) return in Python 3?
29
What is the result of the expression True + True + False in Python?
30
What is the output of bool(0.0) or bool("")?
31 Which of the following is a valid Python identifier?
32
Why does the statement class = 5 raise an error in Python?
class must be capitalized
class is a reserved keyword
33 A program runs without crashing but produces an incorrect average. What type of error is this?
34
Dividing by zero in x = 5 / 0 produces which kind of error?
35
What is the value of the expression 10 - 4 - 2 in Python?
36
What happens when the following runs: x = 5 then x = x + "3"?
37 By convention, how should a named constant like the value of Pi be written in Python?
38
After a = 3 and b = a and then a = 7, what is the value of b?
39 Why do we use high-level programming languages instead of machine code directly?
40 Which statement best describes Python as a programming language?
41
What is the result of evaluating 2 ** 3 ** 2 in Python?
42
What does 0.1 + 0.2 == 0.3 evaluate to in Python, and why?
True, after automatic rounding
False, because == is invalid for floats
False, due to floating-point representation error
True, since decimals are exact
43
What is the output of round(2.5) + round(3.5)?
44
After executing a, b = 1, 2 then a, b = b, a + b, what are the values of a and b?
a = 3, b = 2
a = 2, b = 3
a = 1, b = 3
a = 2, b = 4
45
What is the result of True + True + False in Python?
TypeError
True
46
What is the value of -7 // 2 in Python?
47
What does -7 % 3 evaluate to in Python?
48
What is the output of 2 + 3 * 4 ** 2 // 5 - 1?
49
Given x = 5, what is the value of x after x //= 2; x **= 2; x -= 1?
50 Which of the following is a valid Python identifier?
total-sum
_total2
2total
class
51
What is the output of int("10", 2) + int("10")?
52
What is the type and value of 5 / 5 in Python 3?
float, 1
float, 1.0
int, 1
int, 1.0
53 A program runs without crashing but produces incorrect output. What type of error is this?
54
What is the result of not True == False in Python?
TypeError
False
None
True
55
What does 5 & 3 | 2 evaluate to?
56
After x = y = [1, 2]; x.append(3), what is the value of y?
[1, 2]
[1, 2, 3]
NameError
[3]
57
What is true about a named constant like PI = 3.14159 in Python?
const keyword
58
What is the output of round(3.14159, 2) and its type?
3.15, float
3.14, float
3, int
3.14, str
59
What does the expression 0 or "" or [] or "Python" return?
[]
"Python"
True
0
60 Which statement best describes Python's execution model?
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →