Font size
WorksheetsPython - Chapter 3 Practice Quiz
Total questions: 25
Worksheet time: 13mins
A variable in Python is...
A named container that stores values.
A function that executes code.
A constant value that cannot be changed.
An error encountered during execution.
What does an assignment statement do in Python?
It assigns a value to a variable.
It performs arithmetic operations.
It performs logical operations.
It takes input from the user.
In Python, the '=' symbol...
denotes an assignment operation.
denotes an equality check.
denotes a comparison operation.
denotes a subtraction operation.
The left side of an assignment in Python must be...
A literal
A variable
An expression
A function call
Which of the following is true about Python identifiers?
They can include letters, digits, and underscores, but cannot start with a digit.
They can start with a digit and include any characters.
They must start with an underscore and can only include letters.
They can only consist of digits.
Python is case-sensitive. True or False?
True
False
In Python, what is a floating-point number?
A number with a fractional part, represented with a decimal point.
A whole number without a fractional component.
A number expressed in exponential notation only.
A string representing a number.
What happens when a float value is too large to be represented in Python?
An OverflowError is raised
It becomes infinity
It returns NaN
It remains unchanged
In Python, what is an expression?
It is a combination of values, variables, and operators that can be evaluated to produce a result.
It is a data structure used to store multiple items.
It is a library for creating and managing functions.
It indicates a syntax error in Python.
Best practice for naming variables in Python is:
Use lowercase letters with underscores
Use CamelCase
Use all uppercase letters
Use numbers only
What are the basic arithmetic operators in Python?
a) +, -, *, /
b) %, **, //
c) +, %, **, //
d) -, *, %, //
Fill in the blank: The operator ** is used for ________ in Python.
exponentiation
multiplication
division
modulo
Which operator has the highest precedence in Python?
**
()
*
+
True or False: In Python, the expression x += 1 is shorthand for x = x + 1.
True
False
Fill in the blank: To prevent unintended execution in a Python script, use ________.
if __name__ == "__main__":
if __name__ != "__main__":
if __name__ == "__start__":
if __name__ == "__main__"
What is the correct way to import a module in Python?
import module_name
include module_name
require module_name
module module_name
Fill in the blank: The math module provides advanced mathematical functions such as ________.
sqrt(x), pow(x, y), log(x, base)
abs(x), round(x)
min(x, y), max(x, y)
factorial(x), degrees(x)
Which of the following is a constant provided by the math module?
math.pi
math.sqrt
math.sin
math.log
What is the benefit of using modules in Python programming?
To enhance code organization by grouping related functionalities into separate files, improving reusability and maintainability.
To decrease the speed of program execution.
To increase the length and complexity of the code.
To deliberately add errors to the code.
Fill in the blank: In Python, floating-point numbers use ________ for scientific notation.
e
exp
p
10
What do math functions provide?
A) Basic operations
B) Advanced operations
C) No operations
What is the variable in the code shown
variable
Name
name
What is the output of the following Python code?
x = 5
y = 10
print(x * y)
50
15
5
10
What will be the output of the following code?
x = 10
y = 5
print(x - y)
5
15
10
Error
In Python, a variable needs to
start with letter not number
be stated before "print"
have % symbols on either side
Variable????? We don't need variables!!!!
