
Answer
Question
8 –
CORRECT OPTION –
rstrip
EXPLANATION-
1.strip,lstrip and rstrip function accepts parameter –
characters.
strip removes whitespace characters from start and end of string
by default if no character is passed as argument to function.
lstrip function removes whitespace characters from start of
string by default if no character is passed as argument to
function.
rstrip function removes whitespace characters from end of string
by default if no character is passed as argument to function.
2.So if string = “Hello!”
then string.rstrip(‘!’) returns string “Hello” after removing
character ‘!’ from end of string.
3.Also python has no function called estrip.
Question
9 –
CORRECT OPTION –
list
EXPLANATION-
1.list() method is used to convert tuple to list.
Consider tuple t = (1,2,3,4,5) then list(t) returns list [1, 2,
3, 4, 5]
2.tuple method converts list to tuple object
3.append method is used to add element to end of list
4.insert method accepts 2 parameter – position and element.
It inserts the specified element at the specified position in
list.
Question
10 –
CORRECT OPTION –
equal to
EXPLANATION-
1.if start index is equal to end index then slicing expression
returns empty string even if step is equal to 1 or -1
2.However if start index is greater than end index then slicing
expression returns empty string only if step is equal to 1 not if
step is -1 meaning we are going backwards.
string slice accepts 3 arguments -start index,end index,step and
returns sequence of characters in string from start index till end
index-1 in the increment of step.
if step is not specified then default value is 1.