What will be the output of the following Python code?
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
error
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
none of the mentioned
What will be the output of the following Python code snippet?
print('abef'.replace('cd', '12'))
abef
12
print('a B'.isalpha())
True
False
None
Error
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
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,
startswith()
startswith_prefix()
startswithwith()
startswiths()
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
print('ab cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
None of the mentioned
wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
19
18
17
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
What is the output of the following program:
print ("Hello World"[::-1])
dlroW olleH
Hello Worl
D
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
print('Ab!2'.swapcase())
AB!@
ab12
aB!2
aB1@
White Space
,
e
S
print('abef'.partition('cd'))
(‘abef’)
(‘abef’, ‘cd’, ”)
(‘abef’, ”, ”)
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a
no output
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
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('xyxxyyzxxy'.lstrip('xyy'))
zxxy
xyxxyyzxxy
xyxzxxy
print('abcdefcdghcd'.split('cd'))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
print("xyyzxyzxzxyy".count('xyy', 2, 11))
2
0
1
index()
find()
Both of the above
None of the above
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
count()
upper()
strip()
All the above
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘ab’, ‘cd’, ‘ef’)
copy()
capitalize()
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.
List
Tuple
Dictionary
anywhere in between the file
End
beginning
second line of the file
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
abcd
ABCD
print('1Rn@'.lower())
n
1rn@
rn
r
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
a a a a a a … infinite Time
example = "NITIN" print(example.rfind("N"))
-1
4
3
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
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('11'.isnumeric())
print(max("what are you"))
u
t
y
print(''.isdigit())
print('abcdefcdghcd'.split('cd', -1))
print("xyyzxyzxzxyy".count('xyy', -10, -1))
>>>max("what are you")
what
print('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
indexing
Replication
concatenation
None of the Above
example = "snow world"example[3] = 's'print (example)
snow
snow world
snos world
print("xyyzxyzxzxyy".count('yy', 1))
print("abcdef".find("cd"))