What will be the output of the following Python code?
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
a a a a a
a a a a a a
a a a a a a … infinite Time
a
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
What will be the output of the following Python code snippet?
print('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
print('abef'.partition('cd'))
(‘abef’)
(‘abef’, ‘cd’, ”)
(‘abef’, ”, ”)
error
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
none of the mentioned
Concatenation
Membership
Slicing
All of the above
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
Index of 'a'
Frequency of 'a'
Boolean
Error
matches a pattern at the start of the string.
matches a pattern at any position in the string.
such a function does not exist
none of the mentioned.
print('ab'.isalpha())
True
False
None
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
print s[0]
print s.lower()
s[1]='r'
print s.strip()
print('abcdefcdghcd'.split('cd', 2))
[‘ab’, ‘ef’, ‘ghcd’]
[‘ab’, ‘efcdghcd’]
[‘abcdef’, ‘ghcd’]
List
Tuple
Dictionary
x = "abcdef"i = "a"while i in x: x = x[:-1] print(i, end = " ")
i i i i i i
print('a@ 1,'.islower())
print(max("what are you"))
u
t
y
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
23
'2+3'
'23'
None of These
wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
None of the mentioned
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
abcd
ABCD
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.
anywhere in between the file
End
beginning
second line of the file
print("xyyzxyzxzxyy".count('xyy', -10, -1))
2
0
1
print('abef'.replace('cd', '12'))
abef
12
example = "NITIN" print(example.rfind("N"))
-1
4
3
print("abcdef".find("cd") == "cd" in "abcdef")
example = "snow world"example[3] = 's'print (example)
snow
snow world
snos world
slicer
None of these-
length
length()
len()
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘ab’, ‘cd’, ‘ef’)
19
18
17
count()
upper()
strip()
All the above
string = "my name is x"for i in string.split(): 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,
find()
copy()
capitalize()
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
print('xyxxyyzxxy'.lstrip('xyy'))
xyxxyyzxxy
xyxzxxy
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 cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
print('a B'.isalpha())
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
world
helloworld
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
print('Hello World'.istitle())
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
उपरोकà¥à¤¤ सà¤à¥€
print('HelloWorld'.istitle())
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]