WorksheetsTest11
Total questions: 30
Worksheet time: 30mins
Which of the following describes the role of a Python interpreter?
It converts Python code into Java bytecode.
It executes Python code line by line, translating it just-in-time.
It translates the entire source code into machine code before execution.
It's primarily used for debugging Python applications only.
Which of the following is NOT a fundamental property of the Python language?
Statically typed
Object-oriented
Uses significant indentation
Interpreted
Which of these are valid Python keywords?
do...while
typedef
yield
return
What is the output of the following code?
A
A B C
B C
C
How would you correctly represent the logical literal 'false' in Python?
false
False
0
NULL
What is the output of print(type(0.0034))?
<class 'float'>
<class 'int'>
<class 'decimal'>
float
Which of the following are valid ways to include a comment in Python?
# This is a comment
'''This is a\nmulti-line comment'''
// This is a comment
/* This is a comment */
What will the code print(input('Enter value: ')) display and then wait for?
It will display nothing, just wait for input.
It will display 'Enter value: ' and then print the user's input.
It will display 'Enter value: ' and then print 'None'.
It will cause a TypeError.
Which number system is most commonly used by computers internally?
Decimal (Base-10)
Binary (Base-2)
Hexadecimal (Base-16)
Octal (Base-8)
What is the result of 7 // 2 and 7 / 2 respectively?
3 and 3
3 and 3.5
3.5 and 3
3.5 and 3.5
Which operators are used for string repetition and concatenation in Python?
* for repetition, + for concatenation
x for repetition, & for concatenation
repeat() for repetition, join() for concatenation
** for repetition, . for concatenation
If my_value = 10, what will my_value be after my_value -= 3?
3
7
10
Error
Which of the following data types are mutable in Python?
int
list
tuple
str
What is the result of the bitwise operation 10 << 1?
5
10
20
12
Which of the following logical expressions evaluates to True?
not (5 > 3 and 2 < 1)
True or False and False
10 == 10 and not False
False or (True and False)
What does len("Python") return?
6
"Python"
Error
None
You want to print two variables, name and age, on the same line, separated by a comma and a space, and ending with a period. Which print() statement achieves this?
print(name, age, sep= ', ' , end='.')
print(name + ', ' + str(age) + '.')
print(name, age, separator =', ' , end_char='.')
print(f'{name}, {age}.')
What is the data type of the object [1, 2, 3]?
tuple
set
list
dictionary
Which of these statements correctly calculate 23 in Python?
2 ^ 3
2 ** 3
pow(2, 3)
2 * 3
Given my_string = "Python Programming", what is the output of my_string[7:11]?
Prog
Progr
ram
ram
What will be the output of this code?
0 1 2 3 4
0 1 2 3 4 5
Infinite loop
Error
Which of the following are true about the range() function?
It generates a list of numbers.
It can take one, two, or three arguments.
The stop value is exclusive.
It always starts counting from 1.
When does the else block associated with a while loop execute?
When the while loop condition initially evaluates to False.
When the while loop terminates normally (i.e., without a break statement).
Every time the while loop condition is checked and is False.
If an Exception occurs within the loop.
What is the purpose of the break statement in a loop?
To skip the current iteration and move to the next.
To immediately exit the innermost loop.
To restart the loop from the beginning.
To raise an exception.
Given my_list = [10, 20, 30, 40, 50], what is the output of my_list[1:4]?
[10, 20, 30, 40]
[20, 30, 40]
[20, 30, 40, 50]
[10, 20, 30]
Which of the following list methods adds an element at a specific position?
append()
extend()
insert()
add()
Given my_tuple = (1, 2, 3), which of the following operations is valid?
my_tuple[0] = 5
my_tuple.append(4)
new_tuple = my_tuple + (4,) *
del my_tuple[0]
How do you add a new key-value pair ('city': 'London') to an existing dictionary my_dict = {'name': 'Alice'}?
my_dict.add('city', 'London')
my_dict['city'] = 'London'
my_dict.update({'city': 'London'})
my_dict.append('city', 'London')
What is the result of "hello".upper()?
"HELLO"
"Hello"
hello
Error
When a Python function is called, what is the correct term for the actual values passed into the function?
Parameters
Arguments
Return values
Variables
