What will be the output of the following Python code snippet?
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
startswith()
startswith_prefix()
startswithwith()
startswiths()
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
none of the mentioned
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
What will be the output of the following Python code?
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
error
print('a@ 1,'.islower())
True
False
None
Error
print("xyyzxyzxzxyy".count('xyy', -10, -1))
2
0
1
print('a B'.isalpha())
count()
strip()
upper()
उपरोकà¥à¤¤ सà¤à¥€
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
world
helloworld
Removes all spaces from the string.
Removes the first and last character of the string.
Removes whitespace from the beginning and end of the string.
Converts the string into a list of characters.
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
None of the mentioned
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
what will the output of following code
my_string="Hello,world"print(my_string[-6:-1])
,worl
worl
oworld
What is the output of the following program:
print ("Hello World"[::-1])
dlroW olleH
Hello Worl
D
print('xyxxyyzxxy'.lstrip('xyy'))
xyxxyyzxxy
xyxzxxy
print('abef'.replace('cd', '12'))
abef
12
What will be the output of the following expression?
a = 2b = 8print(a|b )print(a >> 1)
10 0
10 2
2 2
10 1
print('ab'.isalpha())
>>>max("what are you")
what
y
a
Concatenation
Membership
Slicing
All of the above
a = [0, 1, 2, 3]for a[0] in a: print(a[0])
0 1 2 3
0 1 2 2
3 3 3 3
print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
xyyxyyxyxyxxy
12y12y1212x12
example = "helle"print(example.find("e"))
-1
example = "helle" print(example.rfind("e"))
4
3
dlroWolleH
d
matches a pattern at the start of the string.
matches a pattern at any position in the string.
such a function does not exist
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
print('Ab!2'.swapcase())
AB!@
ab12
aB!2
aB1@
find()
copy()
capitalize()
none of the mentioned.
List
Tuple
Dictionary
print('11'.isnumeric())
print("abcdef".find("cd") == "cd" in "abcdef")
print('Hello World'.istitle())
print('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
What does the following code print ?
x = 'mohan'for i in range (len(x)): x[i].upper()print (x)
mohan
MOHAN
None of These
print('abcdefcdghcd'.split('cd'))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
string = "my name is x"for i in string: print (i, end=", ")
m, y, , n, a, m, e, , i, s, , x,
m, y, , n, a, m, e, , i, s, , x
my, name, is, x,
indexing
Replication
concatenation
None of the Above
print("xyyzxyzxzxyy".count('yy', 1))
23
'2+3'
'23'
print("xyyzxyzxzxyy".count('xyy', 2, 11))
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘abef’)
(‘ab’, ‘cd’, ‘ef’)
print s[0]
print s.lower()
s[1]='r'
print s.strip()
delete all the trailing whitespace characters
delete all the leading whitespace characters
delete all the leading and trailing whitespace characters
delete upper case characters