1.

Consider the following string mySubject: mySubject = "Computer Science"What will be the output of the following string operations:- print(mySubject[0:len(mySubject)]) print(mySubject[-7:-1]) print(mySubject[::2]) print(mySubject[len(mySubject)-1]) print(2*mySubject) print(mySubject[::-2]) print(mySubject[:3] + mySubject[3:]) print(mySubject.swapcase()) print(mySubject.startswith('Comp')) print(mySubject.isalpha())

Answer» Consider the following string mySubject:

mySubject = "Computer Science"

What will be the output of the following string operations:-

  1. print(mySubject[0:len(mySubject)])

  2. print(mySubject[-7:-1])

  3. print(mySubject[::2])

  4. print(mySubject[len(mySubject)-1])

  5. print(2*mySubject)

  6. print(mySubject[::-2])

  7. print(mySubject[:3] + mySubject[3:])

  8. print(mySubject.swapcase())

  9. print(mySubject.startswith('Comp'))

  10. print(mySubject.isalpha())



Discussion

No Comment Found

Related InterviewSolutions