str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
None
length
length()
len()
What will be the output of the following Python code snippet?
print('Hello World'.istitle())
True
False
Error
What will be the output of the following Python code?
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
error
Concatenation
Membership
Slicing
All of the above
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
0
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('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
19
18
17
print('11'.isnumeric())
List
Tuple
Dictionary
print('a@ 1,'.islower())
islower()
isupper()
Islower()
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('a B'.isalpha())
23
'2+3'
'23'
None of These
print('abcdefcdghcd'.split('cd'))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
delete all the trailing whitespace characters
delete all the leading whitespace characters
delete all the leading and trailing whitespace characters
delete upper case characters
print('abc'.islower())
count()
upper()
strip()
All the above
print('abef'.partition('cd'))
(‘abef’)
(‘abef’, ‘cd’, ”)
(‘abef’, ”, ”)
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
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
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
print('1.1'.isnumeric())
print('ab'.isalpha())
what will the output of following code
my_string="Hello,world"print(my_string[-6:-1])
,worl
worl
world
oworld
dlroWolleH
Hello Worl
d
print(max("what are you"))
u
t
y
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘ab’, ‘cd’, ‘ef’)
2
print('Hello!2@#World'.istitle())
What does the following code print ?
x = 'mohan'for i in range (len(x)): x[i].upper()print (x)
mohan
MOHAN
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
helloworld
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
What is the output of the following program:
print ("Hello World"[::-1])
dlroW olleH
D
print('abef'.replace('cd', '12'))
abef
12
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
print s[0]
print s.lower()
s[1]='r'
print s.strip()
index()
find()
Both of the above
None of the above
wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
anywhere in between the file
End
beginning
second line of the file
print('1Rn@'.lower())
n
1rn@
rn
r
White Space
,
e
S
none of the mentioned.
print('ab cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
None of the mentioned
string = "my name is x"for i in string.split(): print (i, end=", ")
print("xyyzxyzxzxyy".count('yy', 1))
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