Python MCQ
Python MCQ
(a) True (b) False (c) Depends on Program (d) Depends on the computer system
4. Which of the following is the correct statement to compute the square of variable x in Python?
5. If you want to display the values without decimal place after division, which of the following
symbols is used?
10. Evaluate x % y // x, if x = 5, y = 4
(a) Python only evaluates the second argument if the first one is False
(b) Python only evaluates the second argument if the first one is True
16. Which of the following forces an expression to be converted into a specific type?
17. _________________ are stored as individual characters in contiguous locations, with the two-
way index for each location.
19. If n=”Hello” and user wants to assign n[0]=’F’ what will be the result?
(b) It‟s not allowed in Python to assign a value to an individual character using index
21. In list slicing, the start and stop can be given beyond limits. If it is then
(c) return elements falling between specified start and stop values
(a) first element (b) last element (c) second last element (d) second element
24. Ms. Hetvee is working on a string program. She wants to display last four characters of a
string object named s. Which of the following is statement is true?
(a) first (b) last (c) specified index (d) at any location
26. Which of the following statement is true for extend() list method?
(c) ads element at specified index (d) ads elements at random index
(a) deletes elements 2 to 4 elements from the list (b) deletes 2nd and 3rd element from the list
(c) deletes 1st and 3rd element from the list (d) deletes 1st, 2nd and 3rd element from the list
29. Which of the following method is used to delete element from the list?
txt="Term 1"
print(txt*2)
(a) Term 1 Term 2 (b) Term 1Term 1 (c) Term 1 2 (d) TTeerrmm 11
txt="SQP2021"
if txt.isalnum()==True:
print("Term 1 sample paper is out now")
else:
print("Term 1 sample paper is not out till now")
a) Term 1 sample paper is not out till now b) Term 1 sample paper is out now
c) SQP2021 d) Error
t=(4,5,6)
t1=t*2
print(t1)
t=(4,5,6)
del t[1]
print(t)
36. Which of the following operation is supported in python with respect to tuple t?
t=(4,5,6,7,8,9,3,2,1)
print(t[5:-1])
a) (8,9,3,2,1) b) (9,3,2) c) (4,5,6,7) d) (2,3,9)
39. Dictionaries are also known as ________.
41. Mr Subodh is working with a dictionary in python for his project. He wants to display the key, and
value pair but confuse by these statements, choose the correct statement for him:
42. The from keys() method assigns ________ value to key in dictionary by default.
43. Which one of the following is the correct statement for creating a dictionary for assigning a day
number to weekdays using short names?
a) d ={1:Mon,2:Tue,3:Wed,4:Thur} b) d ={1:‟Mon‟,2:‟Tue‟,3:‟Wed‟,4:‟Thur‟}
c) d ={1;‟Mon‟,2;‟Tue‟,3;‟Wed‟,4;‟Thur‟} d) d ={1-„Mon‟,2-„Tue‟,3-„Wed‟,4-„Thur‟}
44. Om is learning the concept of a dictionary in python. He read something about a dictionary related
to a set of elements. But he forgot the term which type of set of elements, suggest from the below-
given options:
45. Eshika is trying to delete an element from the dictionary, but she is getting an error – “the given key
is not found in the dictionary”. Which of the following command she has used in the python
46. Which of the following is the correct statement for checking the presence of a key in the dictionary?
dict={'Manthan':34,'Vishwa':45,'Mayank':50}
print(dict[0])
50. Marks in the above-created dictionary are changed after rechecking, where Vishwa got 48 marks and
Mayank got 49 marks. Choose the correct statement for the same:
a) dict.change({„Vishva‟:48,‟Mayank‟:49})
b) dict.alter({„Vishva‟:48,‟Mayank‟:49})
c) dict.update({„Vishva‟:48,‟Mayank‟:49})
d) dict.loc({„Vishva‟:48,‟Mayank‟:49})
51. What happens when the following statement will be written for the same dictionary created in Que.
No. 49?
dict.update({'Sameer':44})
b) It will add a new key and value at the end of the dictionary
c) It will replace the last key and value with the given key and value
d) It will add a new key and value at the beginning of the dictionary
52. Which of the following code will print output as 3 for the dictionary created in Que. No. 49?
dict={'x':11,'y':13,'z':15}
s=""
for i in dict:
s=s+str(dict[i])+" "
s1=s[:-1]
print(s1[::-1])
a) 15 13 11 b) 11 13 15 c) 51 31 11 d) 10 13 14