What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 1))
2
0
1
none of the mentioned
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
example = "snow world"example[3] = 's'print (example)
snow
snow world
Error
snos world
What will be the output of the following Python code snippet?
print(''.isdigit())
True
False
None
space
colon
semi colon
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
abcd
ABCD
error
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
19
18
17
print('abc'.islower())
print('abcdefcdghcd'.split('cd'))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
dlroWolleH
Hello Worl
d
print('abcdefcdghcd'.split('cd', 2))
[‘ab’, ‘ef’, ‘ghcd’]
[‘ab’, ‘efcdghcd’]
[‘abcdef’, ‘ghcd’]
count()
strip()
upper()
उपरोकà¥à¤¤ सà¤à¥€
print('Ab!2'.swapcase())
AB!@
ab12
aB!2
aB1@
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('abcdefcdghcd'.split('cd', -1))
print('ab,12'.isalnum())
print('abef'.replace('cd', '12'))
abef
12
List
Tuple
Dictionary
White Space
,
e
S
print('Hello World'.istitle())
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C 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
none of the mentioned.
print('HelloWorld'.istitle())
islower()
isupper()
Islower()
print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
xyyxyyxyxyxxy
12y12y1212x12
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('Hello!2@#World'.istitle())
All the above
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
print('11'.isnumeric())
print('a@ 1,'.islower())
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
None of the mentioned
print("abcdef".find("cd"))
3
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
print('abef'.partition('cd'))
(‘abef’)
(‘abef’, ‘cd’, ”)
(‘abef’, ”, ”)
print('ab cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
startswith()
startswith_prefix()
startswithwith()
startswiths()
example = "NITIN" print(example.rfind("N"))
-1
4
what will the output of following code
my_string="Hello,world"print(my_string[-6:-1])
,worl
worl
world
oworld
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
anywhere in between the file
End
beginning
second line of the file
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
a a a a a
a a a a a a … infinite Time
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,
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘ab’, ‘cd’, ‘ef’)
print("abcdef".find("cd") == "cd" in "abcdef")
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]