
Q91
Q91 Pseudocode:
Initialize a variable with "Python", print first and last character
Prints "Pn"
Prints "Py"
Prints "Python"
Error
Q92
Q92 Find the mistake:
user_input = input("Enter a number: ");
print("You entered: ", int(user_input))
Syntax error
No error
int() should be str()
input() function used incorrectly
Q93
Q93 What is the purpose of an if statement in Python?
To loop through a sequence
To execute a block conditionally
To define a function
To handle exceptions
Q94
Q94 In Python, which keyword is used to check additional conditions if the previous conditions fail?
elif
else if
then
switch
Q95
Q95 Which of the following is a valid conditional statement in Python?
if a = 5:
if a == 5:
if a <> 5:
if (a = 5):
Q96
Q96 Pseudocode:
If age > 18,
print "Adult",
else
print "Minor"
Prints "Adult"
Prints "Minor"
Prints "Age"
No output
Q97
Q97 Pseudocode: What is printed when the temperature is 25 degrees?
If temperature > 30,
print "Hot",
elif temperature > 20,
print "Warm",
else
"Cold"
Prints "Hot"
Prints "Warm"
Prints "Cold"
No output
Q98
Q98 Find the mistake:
if x > 5:
print("Yes")
elif x < 10:
print("No")
Syntax error in the if block
Missing colon after elif
Missing else between blocks
No error
Q99
Q99 Which statement immediately terminates a loop in Python?
break
continue
exit
stop
Q100
Q100 In a while loop, what happens if the condition never becomes False?
The loop runs forever
The loop stops after 10 iterations
Syntax error
The loop doesn't start
Q101
Q101 What will the following code print?
i = 5;
while i > 0:
print(i);
i -= 1
5 4 3 2 1
5 4 3 2
1 2 3 4 5
Infinite loop
Q102
Q102 Pseudocode:
For each element in list [1, 2, 3],
print element
Prints 1 2 3
Prints 3 2 1
Prints [1, 2, 3]
No output
Q103
Q103 Pseudocode:
For i = 0 to 4,
print "Python"
if i is even
Prints "Python" twice
Prints "Python" three times
Prints "Python" four times
No output
Q104
Q104 How is memory allocation for lists and tuples different in Python?
Lists use more memory than tuples
Tuples use more memory than lists
Both use the same amount of memory
Memory usage is random and unpredictable
Q105
Q105 What will be the output of the following code?
myTuple = (1, 2, 3);
print(myTuple[1])
1
2
3
Error
Q106
Q106 What is the result of the following code?
myList = [1, 2, 3];
myList[1] = 4;
print(myList)
[1, 2, 3]
[1, 4, 3]
Error
[4, 2, 3]
Q107
Q107 Pseudocode:
Initialize list with values [1,2,3];
Add 4 to the end;
Print list
Prints [1, 2, 3]
Prints [1, 2, 3, 4]
Error
Prints [4, 1, 2, 3]
Q108
Q108 Pseudocode:
Given a tuple (1,2,3),
print each element multiplied by 2
Prints 2, 4, 6
Prints 1, 2, 3
Error
No output
Q109
Q109 Find the mistake:
myTuple = (1, 2, 3);
myTuple[1] = 4
Tuples are immutable
Wrong index used
Syntax error in tuple declaration
myTuple should be a list
Q110
Q110 What is a dictionary in Python?
An ordered collection of elements
A mutable collection of key-value pairs
An immutable collection of items
A collection of unique elements
Q111
Q111 What happens if you try to access a non-existent key 'k' in a dictionary 'd' using d[k]?
Returns None
Returns an empty string
Raises a KeyError
Creates a new key 'k' with value None
Q112
Q112 How can you remove a key-value pair from a dictionary?
Using the del statement
Using the remove() method
Using the pop() method
Both A and C
Q113
Q113 In Python 3.7 and later, how are elements in a dictionary ordered?
By the order they were added
In ascending order of keys
In descending order of keys
Randomly
Q114
Q114 What is the output of the following code?
d = {'a': 1, 'b': 2};
print(d['b'])
1
2
b
KeyError
Q115
Q115 What will be the result of the following code?
d = {'a': 1, 'b': 2};
d['c'] = 3;
print(len(d))
2
3
Error
1
Q116
Q116 Pseudocode:
Initialize dictionary with {'a': 1, 'b': 2};
Update 'b' value to 3;
Print dictionary
Prints {'a': 1, 'b': 2}
Prints {'a': 1, 'b': 3}
Error
No output
Q117
Q117 Pseudocode:
Given a dictionary,
print each key-value pair
Prints keys only
Prints values only
Prints key-value pairs
Error
Q118
Q118 Identify the error:
d = {['first']: 1, ['second']: 2}
Syntax error with the dictionary
Lists can't be dictionary keys
No error
Dictionary keys must be strings
Q119
Q119 What is a function in Python?
A variable
A module
A block of code
An operator
Q120
Q120 What will the following function return:
def example():
return 5+5
5+5
10
0
None

