NEW
Font size
WorksheetsPython
Total questions: 20
Worksheet time: 10mins
Which of the following is a valid Python identifier?
1variable
_variable
variable name
variable-name
Which of the following is not a valid naming convention for Python identifiers?
snake_case
PascalCase
camelCase
kebab-case
What is the maximum length of a Python identifier?
32 characters
64 characters
128 characters
There is no maximum length
Which of the following is not a reserved word in Python and can be used as an identifier?
if
for
and
while
Which of the following is true about Python identifiers?
They are case-sensitive.
They can start with a digit.
They can contain special characters like @ or #.
They can be a Python built-in function name.
Which of the following is not a built-in data type in Python?
int
float
string
array
What is the difference between a tuple and a list in Python?
Tuples are mutable, and lists are immutable.
Tuples are ordered, and lists are unordered.
Tuples are enclosed in parentheses, and lists are enclosed in square brackets.
Tuples can contain elements of different data types, while lists can only contain elements of the same data type.
Which data type is used to represent a Boolean value in Python?
bool
boolean
bit
logical
Which data type is used to represent a collection of key-value pairs in Python?
dictionary
set
tuple
array
Which of the following data types is mutable in Python?
int
float
tuple
list
What happens when you modify an immutable object in Python?
The object's value is changed directly.
The object is replaced with a new object that has the modified value.
It is not possible to modify immutable objects in Python.
The modification results in a runtime error.
What is the purpose of comments in Python?
To make the code execute faster.
To mark the end of a code block.
To explain or clarify the code for humans.
To generate error messages during runtime.
Which data type is used to represent a collection of key-value pairs in Python?
dictionary
set
tuple
array
How are single-line comments denoted in Python?
/* ... */
<!-- ... -->
// ...
# ...
Which of the following is an appropriate use case for comments in Python?
Storing important data within comments.
Commenting out large sections of code temporarily.
Creating executable code that runs during runtime.
Changing the behavior of the program based on comments.
What happens to comments when you execute a Python program?
They are completely ignored and not executed.
They are executed as regular code.
They generate runtime errors.
They are executed but have no effect on the program's output.
Can comments span multiple lines in Python?
Yes, using the // symbol.
Yes, using the /* ... */ symbols.
Yes, using triple quotes (''' ... ''') or (# ... #).
No, comments must always be on a single line.
Which operator is used for exponentiation in Python?
^
**
*
//
What is the result of the expression 10 / 3 in Python?
3.33
3
3.0
3.333
What is the result of the expression "Hello" + "World" in Python?
HelloWorld
Hello World
Hello+World
Error: unsupported operand type(s) for +: 'str' and 'str'
