ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Python MCQ Practice Questions SET 5
2
3
Sr. No.QuestionOption 1Option 2Option 3Option 4Correct Option
4
41dict1={} what is the meaning of thiswill create empty dictionarywill return empty dictionarysyntax errornone of aboveA
5
42Which module can be used to create constant variables in Python?constant moduleconstants moduleconst moduleConsts moduleA
6
43Which function is used to convert a string to uppercase in Python?str.upper()str.lower()str.find()str.strip()A
7
44What is the purpose of the str.strip() function in Python?To split a string into a list of substringsTo remove leading and trailing white spaces from a stringTo find the index of a substring within a stringTo replace occurrences of a substring with another substringB
8
45Which function is used to replace occurrences of a substring with another substring in a given string in Python?str.upper()str.lower()str.replace()str.join()C
9
46What does the len() function return in Python when applied to a string?The number of characters in the stringThe number of words in the stringThe number of lines in the stringThe number of bytes in the stringA
10
47Which method of string concatenation is used to join elements of a list into a single string in Python?str.concat()str.combine()str.concatenate()str.join()D
11
48What is the output of the following code snippet?'students, please, practice, Python, programs''students please practice Python programs''students, please, practice, Python, , programs''students, please, practice, Python, ; programs'A
12
49Which function is used to find the index of the first occurrence of a substring within a string in Python?str.upper()str.lower()str.find()str.strip()C
13
50What is the purpose of the format() function in Python?To convert a string to lowercaseTo format strings based on specific parametersTo find the length of a stringTo convert a string to uppercaseB
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100