Computer Science
Given str1 = "Hello", what will be the values of:
(a) str1[0]
(b) str1[1]
(c) str1[-5]
(d) str1[-4]
(e) str1[5]
Python Data Handling
80 Likes
Answer
(a) H
(b) e
(c) H
(d) e
(e) IndexError: string index out of range
Explanation
Answered By
25 Likes
Related Questions
Two objects (say a and b) when compared using == ,return True. But Python gives False when compared using is operator. Why? (i.e., a == b is True but why is a is b False?)
What is the difference between implicit type conversion and explicit type conversion?
What will the result given by the following?
(a) type (6 + 3)
(b) type (6 -3)
(c) type (6 *3)
(d) type (6 / 3)
(e) type (6 // 3)
(f) type (6 % 3)
If you give the following for str1 = "Hello", why does Python report error?
str1[2] = 'p'