adplus-dvertising
frame-decoration

Question

What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]

a.

olleh

b.

hello

c.

h

d.

o

Posted under Strings in Python Python

Answer: (d).o

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output when following code is executed ?

Similar Questions

Discover Related MCQs

Q. What arithmetic operators cannot be used with strings ?

Q. print(0xA + 0xB + 0xC) :

Q. Given a string example=”hello” what is the output of example.count(l)

Q. To concatenate two strings to a third what statements are applicable ?

Q. Which of the following statement prints hello\example\test.txt ?

Q. Suppose s is “\t\tWorld\n”, what is s.strip() ?

Q. The format function, when applied on a string returns :

Q. What is the output of “hello”+1+2+3 ?

Q. What will be displayed by print(ord(‘b’) – ord(‘a’)) ?

Q. Say s=”hello” what will be the return value of type(s) ?

Q. What is “Hello”.replace(“l”, “e”)

Q. To retrieve the character at index 3 from string s=”Hello” , what command do we execute ?

Q. To return the length of string s what command do we execute ?

Q. If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.

Q. To check whether string s1 contains another string s2, use

Q. Suppose i is 5 and j is 4, i + j is same as

Q. What function do you use to read a string?

Q. Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space)

Q. What is the default value of encoding in encode()?