CBSE Class 11 Computer Science Question 85 of 173

Data Handling — Question 14

Back to all questions
14
Question

Question 14

Given str1 = "Hello", what will be the values of:

(a) str1[0]

(b) str1[1]

(c) str1[-5]

(d) str1[-4]

(e) str1[5]

Answer

(a) H

(b) e

(c) H

(d) e

(e) IndexError: string index out of range

Explanation

H05e14l23l32o41\begin{matrix} \underset{-5}{\overset{0}{\bold{H}}} & \underset{-4}{\overset{1}{\bold{e}}} & \underset{-3}{\overset{2}{\bold{l}}} & \underset{-2}{\overset{3}{\bold{l}}} & \underset{-1}{\overset{4}{\bold{o}}} \end{matrix}

Answer