Computer Science, asked by kausarnik1012, 2 months ago

Write the python statement and the output for the following:

(a) To break the string 'Revolution' into 3 parts taking ‘l’ as separator.

(b) Change the case of each letter in string ‘ScHoOl’.

(c) Whether ‘S’ exists in string ‘Schedule’ or not.​

Answers

Answered by Equestriadash
11

(a) To break the string 'Revolution' into 3 parts taking, ‘l’ as the separator.

>>> "Revolution".partition('l')

('Revo', 'l', 'ution')

(b) To change the case of each letter in the string ‘ScHoOl’.

>>> 'ScHoOl'.swapcase()

'sChOoL'

(c) Whether ‘S’ exists in the string ‘Schedule’ or not.​

>>> 'S' in 'Schedule'

True

  • partition() is a method used to split a string using the specified separator in the argument. It returns a tuple, with the substring before the separator, the separator and the substring after the separator.
  • swapcase() is a method that is used to change the case of the string it's used with.
  • The in operator is used to check if an element is present in another element or not. It's opposite would be the not in operator.

Anonymous: Awesome Diddu! :D
Equestriadash: Thank you! ^_^"
Similar questions