indexing
Replication
concatenation
None of the Above
What will be the output of the following Python code?
print('1Rn@'.lower())
n
1rn@
rn
r
What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
error
none of the mentioned
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.
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,
19
18
17
Error
print('ab,12'.isalnum())
True
False
None
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
print('abc'.islower())
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
print('Hello!2@#World'.istitle())
print('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
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
string = "my name is x"for i in string.split(): print (i, end=", ")
print s[0]
print s.lower()
s[1]='r'
print s.strip()
example = "helle"print(example.find("e"))
-1
1
0
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
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.
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
print('abef'.replace('cd', '12'))
abef
12
print('11'.isnumeric())
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
print('abcdefcdghcd'.split('cd', 2))
[‘ab’, ‘ef’, ‘ghcd’]
[‘ab’, ‘efcdghcd’]
[‘abcdef’, ‘ghcd’]
print('Ab!2'.swapcase())
AB!@
ab12
aB!2
aB1@
White Space
,
e
S
count()
upper()
strip()
All the above
print('1.1'.isnumeric())
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
None of the mentioned
startswith()
startswith_prefix()
startswithwith()
startswiths()
Concatenation
Membership
Slicing
All of the above
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
>>>max("what are you")
what
y
example = "snow world"example[3] = 's'print (example)
snow
snow world
snos world
List
Tuple
Dictionary
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
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
print("abcdef".find("cd"))
2
3
print(max("what are you"))
u
t
islower()
isupper()
Islower()
print("xyyzxyzxzxyy".count('yy', 1))
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
find()
copy()
capitalize()
length
length()
len()
example = "NITIN" print(example.rfind("N"))
4
print('xyxxyyzxxy'.lstrip('xyy'))
zxxy
xyxxyyzxxy
xyxzxxy
space
colon
semi colon
print("xyyzxyzxzxyy".endswith("xyy"))