Which method could be used to strip specific characters from the end of a string?

NetherCraft 0
QUESTION 8 Which method could be used to strip specific characters from the end of a string? estrip rstrip strip remove QUEST

Answer

QUESTION 8 Which method could be used to strip specific characters from the end of a string? O estrip strip strip remove QUES

Question
8

Also Check This  When your friend flies by you in a spaceship at half the speed of light. you observe that

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!”

Also Check This  All else held constant. the law of demand suggests that as

then string.rstrip(‘!’) returns string “Hello” after removing
character ‘!’ from end of string.

[2] : string Hello! print(string.rstrip(!)) Hello

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]

[3]: t = (1,2,3,4,5) = print(list(t)) [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.

Also Check This  how many bytes = 1 KB? how many KB = 1 MB? and how many MB?

[17]: data = Spring data[2:2:-1] [17]: + Code + Markdown [ ]: data[2:2:1] [18]: data[4:2:1] [18]: 1 data[4:2:-1] [19]: ni

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.


Leave a Reply

Your email address will not be published. Required fields are marked *