Question 66Asked in DSSSB PGT Computer Science (Technical), 11 Jul 2021

What is output of the code in Python Language: >>> str1 = 'All the Best'

What is output of the code in Python Language: >>> str1 = 'All the Best' >>> str1[-3]
  1. A'l'
  2. B'e'
  3. C'h'
  4. D'B'
Show answerHide answer

Correct answer: (B) 'e'

Explanation

'All the Best' has 12 characters, so index −3 is index 9. Indexes 8-11 are B, e, s, t, so str1[-3] is 'e'.

From DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021

This is question 66 of DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.