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?
print('ab'.isalpha())
True
False
None
Error
What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', 2))
[‘ab’, ‘ef’, ‘ghcd’]
[‘ab’, ‘efcdghcd’]
[‘abcdef’, ‘ghcd’]
none of the mentioned
anywhere in between the file
End
beginning
second line of the file
print("xyyzxyzxzxyy".count('xyy', 2, 11))
2
0
1
error
example = "helle"print(example.find("e"))
-1
print('a B'.isalpha())
print('Hello World'.istitle())
x = "abcdef"i = "a"while i in x: x = x[:-1] print(i, end = " ")
i i i i i i
a a a a a a
a a a a a
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
print(max("what are you"))
u
t
y
print s[0]
print s.lower()
s[1]='r'
print s.strip()
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
find()
copy()
upper()
capitalize()
example = "snow world"example[3] = 's'print (example)
snow
snow world
snos world
print("xyyzxyzxzxyy".endswith("xyy"))
3
White Space
,
e
S
indexing
Replication
concatenation
None of the Above
print('ab,12'.isalnum())
count()
strip()
All the above
Concatenation
Membership
Slicing
All of the above
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
>>>max("what are you")
what
a
print("abcdef".find("cd") == "cd" in "abcdef")
None of the mentioned
print('1Rn@'.lower())
n
1rn@
rn
r
index()
Both of the above
None of the above
print('11'.isnumeric())
print('abef'.replace('cd', '12'))
abef
12
length
length()
len()
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
startswith()
startswith_prefix()
startswithwith()
startswiths()
print(''.isdigit())
wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
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
space
colon
semi colon
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
what will the output of following code
my_string="Hello,world"print(my_string[-6:-1])
,worl
worl
world
oworld
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("xyyzxyzxzxyy".count('yy', 1))
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,
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
19
18
17
islower()
isupper()
Islower()
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd