CBSE Class 11 Computer Science Question 12 of 19

Strings in Python — Question 9

Back to all questions
9
Question

Question 8

Write the Python statement and the output for the following:

(a) Find the third occurrence of 'e' in 'sequence'.

(b) Change the case of each letter in string 'FuNcTioN'.

(c) Whether 'Z' exists in string 'School' or not.

Answer

(a)

s = 'sequence'
index = s.find('e', s.find('e', s.find('e') + 1) + 1)
print(index)
Output
7

(b)

s = 'FuNcTioN'
print(s.swapcase())
Output
fUnCtIOn

(c)

s = 'School'
print('Z' in s)
Output
False