WorksheetsIT 403 - MIDTERM REVIEW (1)
Total questions: 50
Worksheet time: 32mins
Which statement best describes Python's execution model?
Python compiles all code before execution begins
Python translates and executes code line by line in real-time
Python only executes compiled bytecode files
Python requires manual compilation by the programmer
Python prioritizes code readability and simplicity over raw performance in its design philosophy.
True
False
What happens when Python encounters a lexical error during interpretation?
Python automatically corrects the error
Python skips the problematic code and continues
Python stops execution and reports the error location
Python converts the error to a warning
High-level programming languages like Python provide abstractions that more closely match human thinking patterns.
True
False
Python's interpreted nature makes it particularly suitable for:
System-level programming only
High-performance computing only
Rapid prototyping and interactive development
Embedded systems only
Which variable name follows Python naming conventions?
user-name
user_name
1st_user
class
The expression int(3.99) returns 4.
True
False
(a)
What is the result of 15 // 4 * 2?
7.5
6
7
8
What data type is returned by this expression?
(a)
What does this code output if user enters 25?
<class 'int'>
<class 'float'>
<class 'str'>
<class 'number'>
String concatenation using + creates a new string object since strings are immutable.
True
False
(a)
Which escape sequence represents a tab character?
\n
\t
\r
\b
What happens with float("3.14.15")?
Returns 3.14
Returns 3.1415
Raises ValueError
Returns 0
Which value is considered truthy in Python?
0
[]
""
"0"
(a)
The expression [] == False evaluates to True.
True
False
What is the output?
123
13
12
23
(a)
Given mylst = [10, 20, 30, 40, 50], what does mylst[1::2] return?
[10, 30, 50]
[20, 40]
[20, 30, 40]
[10, 20]
The expression True or (x/0) will always raise a ZeroDivisionError.
True
False
What is the result of 7 ^ 3 (bitwise XOR)?
(a)
What happens with this list operation?
[1, 2, 3]
[1, 2, 3, 4]
Error
[4]
What is the output?
2468
246
24
2480
(a)
List slicing can never raise an IndexError, even with invalid indices.
True
False
What is the result of not False and True or False?
True
False
Error
None
(a)
Which of the following does not create a shallow copy of a list?
new_list = old_list
new_list = old_list[:]
new_list = old_list.copy()
Both new_list = old_list[:] and new_list = old_list.copy()
What is the output?
Hello, World!
Hello, Python!
Error
Hello, !
Hello, Python!
Hello, World!
Hello, World!
Tuples can contain mutable objects like lists as their elements.
True
False
The value of result is:
(a)
What happens when accessing a non-existent dictionary key?
Returns None
Returns empty string
Raises KeyError
Returns 0
(a)
Lambda functions can be assigned to variables and used like regular functions.
True
False
What is the output?
Success
Success
No error
Done
Success
Done
Error
Done
(a)
Which function parameter allows accepting any number of keyword arguments?
*args
**kwargs
*params
**options
The finally block executes even if there's a return statement in the try block.
True
False
(a)
What does dict.get('key', 'default') do when 'key' doesn't exist?
Raises KeyError
Returns None
Returns 'default'
Returns empty string
What is the output?
(1, [2, 3], 4)
(1, [2, 3, 5], 4)
Error
(1, 5, 4)
(a)
Dictionary keys must be unique, but values can be duplicated.
True
False
What is the difference between import math and from math import sqrt?
No difference
First imports entire module, second imports specific function
Second is faster
First is deprecated
The __init.py__ file can be empty but must exist for a directory to be treated as a package.
True
False
When this file is imported as a module, the output is:
(a)
Which PIP command creates a requirements.txt file with all installed packages?
pip list > requirements.txt
pip freeze > requirements.txt
pip export > requirements.txt
pip save > requirements.txt
What does from package import * do?
Imports everything from the package
Imports only functions defined in all
Imports the package itself
Causes an error
