slicer
Slicing
Membership
None of these-
anywhere in between the file
End
beginning
second line of the file
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
>>>max("what are you")
what
y
Error
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,
error
count()
upper()
strip()
All the above
What will be the output of the following Python code snippet?
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
print('Hello!2@#World'.istitle())
True
False
None
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
print("xyyzxyzxzxyy".endswith("xyy"))
1
3
2
space
colon
semi colon
print('abcdefcdghcd'.split('cd', 2))
[‘ab’, ‘ef’, ‘ghcd’]
[‘ab’, ‘efcdghcd’]
[‘abcdef’, ‘ghcd’]
none of the mentioned
print("xyyzxyzxzxyy".count('yy', 1))
0
print('abc'.islower())
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
no output
print('a@ 1,'.islower())
print('ab cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
None of the mentioned
print('Hello World'.istitle())
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
islower()
isupper()
Islower()
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
23
'2+3'
'23'
None of These
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
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
startswith()
startswith_prefix()
startswithwith()
startswiths()
print('1.1'.isnumeric())
index()
find()
Both of the above
None of the above
Concatenation
All of the above
print('11'.isnumeric())
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".endswith("xyy", 0, 2))
print("xyyzxyzxzxyy".count('xyy', -10, -1))
what will the output of following code
my_string="Hello,world"print(my_string[-6:-1])
,worl
worl
world
oworld
List
Tuple
Dictionary
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
print s[0]
print s.lower()
s[1]='r'
print s.strip()
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
उपरोकà¥à¤¤ सà¤à¥€
length
length()
len()
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
helloworld
print('a B'.isalpha())
print(''.isdigit())
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("abcdef".find("cd") == "cd" in "abcdef")
print('abef'.partition('cd'))
(‘abef’)
(‘abef’, ‘cd’, ”)
(‘abef’, ”, ”)
print('abcdefcdghcd'.split('cd'))
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘ab’, ‘cd’, ‘ef’)
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy