Review each question and reveal answers to strengthen your understanding
1 Following is an example of ___________________
sv = “csiplearninghub.comâ€
✅ Correct Answer: 1
2Write the output of the following.
a = "Blog"
a ='a'
print(a)
✅ Correct Answer: 4
3Write the output of the following:
a="We
to my
b ok"
print(a)
✅ Correct Answer: 1
4Write the output of the following code :
a= "Welcome to "my" blog"
print(a)
✅ Correct Answer: 1
5Write the output of the following code :
a= "Welcome to
blog"
print(a)
✅ Correct Answer: 1
6Write the output of the following code :
str = "Welcome"
str[2] = 'a'
print(str)
✅ Correct Answer: 2
7Write the output of the following code :
str = "Welcome"
l=len(str)
print(l)
✅ Correct Answer: 2
8 What we call the following:
✅ Correct Answer: 1
9 Write the output of the following code :
a = '''A
B
C'''
print(a)
✅ Correct Answer: 3
10 What is the index value of ‘i’ in string “Learningâ€
✅ Correct Answer: 1
11Index value in String should be of type ________________
✅ Correct Answer: 2
12 What type of error is returned by the following :
str = "Learning"
print(str[10])
✅ Correct Answer: 3
13Which character will have same index value when you access elements from the beginning and from the end(ignore the negative sign) in the following string.
s = “Welcome to my blogâ€
✅ Correct Answer: 3
14Which of the following statement is correct in accessing each element of string?a)
a="Learning"
while(i):
print(i)
b)
a="Learning"
for i in a:
print(i)
✅ Correct Answer: 2
15Name the function which is used to find length of string.
✅ Correct Answer: 2
16 Write the output of the following code :
for i in "STR":
print(i)
✅ Correct Answer: 4
17 Write the output of the following code :
a="Learn"
while(a):
print(a)
✅ Correct Answer: 3
18Which operator is used with integers as well as with strings?
✅ Correct Answer: 4
19Write the output of the following:
2 + '3'
✅ Correct Answer: 4
20 Which operator is used for string concatenation?
✅ Correct Answer: 3
21Write the output of the following code :
for i in (1,2,3):
print("@" * i)
✅ Correct Answer: 3
22How many operators are used in the following statement?
7 + 4 * 8 // 2 ** 2 - 6 / 1
✅ Correct Answer: 2
23Write the output of the following code :
s="blog"
for i in range(-1,-len(s),-1):
print(s[i],end="$")
✅ Correct Answer: 2
24Write the output of the following code :
s= "str"
s1 = "string"
print(s1 in s)
✅ Correct Answer: 2
25Write the output of the following code :
s= "str"
Write the output of the following code :
for i in range(65,70):
print(chr(i))
✅ Correct Answer: 1
26Write the output of the following code :
s= "str"
Write the output of the following code :
for i in range(65,70):
print(chr(i))
✅ Correct Answer: 1
27Write the output of the following:
print(“A#B#C#D#Eâ€.split(“#â€,2))
✅ Correct Answer: 1
28Write the output of the following:
print(“A#B#C#D#Eâ€.replace(“#â€,â€?â€))
✅ Correct Answer: 2
29Write the output of the following:
print(“I love my Countryâ€.find(“oâ€,4))
✅ Correct Answer: 3
30Write the output of the following.
print(‘#’.join(“12345â€))
✅ Correct Answer: 3
31Which of the following is not a String built in functions?
✅ Correct Answer: 4
32Write the output of the following:
print(len("\\\///"))
✅ Correct Answer: 4
33Which of the following function returns the ASCII/Unicode value character?
✅ Correct Answer: 2
34Which of the following statements will also return the same result as given statement? print(“Computer†+ “Computerâ€)
✅ Correct Answer: 4
35Write the output of the following:
for i in range(len("python"),12,2):
print("python"[i-6])
✅ Correct Answer: 1
36Which of the following is a mapping data type?
✅ Correct Answer: 4
37A _____________ can be created by enclosing one or more characters in single, double or triple quote
✅ Correct Answer: 1
38Characters in a string can be _________ enclosed in quotes.
✅ Correct Answer: 3
39Each individual character in a string can be accessed using a technique called _____
✅ Correct Answer: 1
40If we give index value out of the range then we get an ___
✅ Correct Answer: 2
41The index of the first character ____________ on the string is 0
✅ Correct Answer: 1
42What type of error is returned by statement :
>>> str[1.5]
✅ Correct Answer: 4
43Write the output of the following.
str = “pythonâ€
print(str[2+1])
✅ Correct Answer: 1
44Content of string can not be changed, it means that string is
✅ Correct Answer: 2
45 Python allows _____________ operations on string data type.
✅ Correct Answer: 4
46_________ method is used to access some part of a string or substring.>>> str1 = ‘Hello World!’ >>> ‘W’ in str1
✅ Correct Answer: 2
47 str[5 : 11] will return ___________ character
✅ Correct Answer: 2
48str[11 : 5] will return _________
✅ Correct Answer: 1
49Slice operation can also take a third parameter that specifies the _____
✅ Correct Answer: 3
50Which of the following is correct slicing operation to extract every kth character from the string str1 starting from n and ending at m-1.
✅ Correct Answer: 3
51Which of the following will return reverse string str1?
✅ Correct Answer: 1
52We can access each character of a string or traverse a string using ___
✅ Correct Answer: 3
53Which of the following function returns the string with first letter of every word in the string in uppercase and rest in lowercase?
✅ Correct Answer: 3
54Write the output of the following:
s = †Helloâ€
print(s.find(‘a’))
✅ Correct Answer: 2
55What index value is returned by the following code?
s = “Helloâ€
print(s.find(‘l’))
✅ Correct Answer: 1
56Following code will return ?
s = “Helloâ€
print(s.count(‘l’,2,5))
✅ Correct Answer: 1
57Name a function which is same as find() but raises an exception if the substring is not present in the given string.
✅ Correct Answer: 1
58Write the output of the following.
>>> str1 = ‘Hello World! Hello
>>> str1.index(‘Hee’)
✅ Correct Answer: 3
59Write the output of the following.
>>> str1 = ‘Hello World!’
>>> str1.endswith(‘World!’)
✅ Correct Answer: 1
60 Write the output of the following.
s = “hello 123â€
print(s.islower())
✅ Correct Answer: 2
61Write the output of the following:
>>> str1 = 'hello WORLD!'
>>> str1.title()
✅ Correct Answer: 2
62Write the output of the following :
>>> str1 = ‘HelloWorld!!’
>>> str1.isalnum()
✅ Correct Answer: 1
63Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello',12,25)
✅ Correct Answer: 1
64 Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello')
✅ Correct Answer: 3
65Write the output of the following :
print("Absbcbcgdbc".count("b",4))
✅ Correct Answer: 2
66Write the output of the following :
print("Absbcbcgdbc".find("b",5))
✅ Correct Answer: 3
67Which of the following function returns the index value of first occurrence of substring occurring in the given string.
✅ Correct Answer: 3
68find( ) function returns ___________ if the substring is not present in the given string
✅ Correct Answer: 3
69index( ) function returns _______________ if the substring is not present in the given string
✅ Correct Answer: 4
70>>> “Hey!â€.endswith(‘!’) will return ______
✅ Correct Answer: 1
71Which of the function returns Boolean value?
✅ Correct Answer: 4
72Write the output of the following:
>>> str1 = 'String MCQ'
>>> str1.startswith('Str')
✅ Correct Answer: 1
73Write the output of the following:
print("Welcome-Python".isalnum())
✅ Correct Answer: 2
74Write the output of the following:
print(str("WelcomePython".isalnum()).upper())
✅ Correct Answer: 1
75Write the output of the following:
>>> str1 = 'hello ??'
>>> str1.islower( )
✅ Correct Answer: 2
76Which of the following function returns True if the string is non-empty and has all uppercase alphabets.
✅ Correct Answer: 2
77Write the output of the following:
>>> str1 = 'Hello World!'
>>> str1.replace('o' , '*')
✅ Correct Answer: 2
78Write the output of the following:
>>> str1 = 'India is a Great is Country'
>>> str1.partition('is')
✅ Correct Answer: 1
79Write the output of the following:
str = "Amit is a is a"
s = str.partition('is')
print(s[1])
✅ Correct Answer: 2
80partition( ) function of string in python return the result in the form of ____
✅ Correct Answer: 3
81partition() function divides the main string into ________ substring.
✅ Correct Answer: 3
82split( ) function returns the _______________of words delimited by the specified substring.
✅ Correct Answer: 1
83If no delimiter is given in split( ) function then words are separated by ____
✅ Correct Answer: 1
84Write the output of the following:
"python".join("@")
✅ Correct Answer: 4
85Write the output of the following:
"@".join("python")
✅ Correct Answer: 1
86Write the output of the following:
>>> len(" python".lstrip()) #2 spaces are given before "python"
✅ Correct Answer: 2
87Which of the following function removes only leading spaces from the string?
✅ Correct Answer: 2
88Which of the following function can take maximum three arguments/parameters?
✅ Correct Answer: 4
89Which of the following function return the integer value?
✅ Correct Answer: 4
90Which of the following is not an inbuilt function of string?
✅ Correct Answer: 1
91Which function in the following statement will execute first?
print("amit".lower().upper())
✅ Correct Answer: 1
92Which function in the following statement will execute last?
print("amit".lower().upper())
✅ Correct Answer: 4
93 Write the output of the following:
print('aisabisacisadisae'.split('isa',3))
✅ Correct Answer: 1
94Write the output of the following:
print('aisabisacisadisae'.split('isa'))
✅ Correct Answer: 3
95print(“aNd&*â€.swapcase()) will display _