Q. Write the Python statement and the output of the following:


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

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

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


Answer :-


a =

s = "expresses"
print("occurrence of 'e' is :-", s.count("e") )


Output :-

occurrence of 'e' is :- 3
>>>

b =

s = "FuNTioN"
new = ""
for i in s :
    if i.isupper():
        new += i.lower()
    else :
        new += i.upper()
        
print("New String :-", new )


Output:-

New String :- fUntIOn
>>>

c =

s = "My School is Pathwalla"

if s.find("School") :
    print("School found")

else :
    print("School Not found")


Output :-

School found
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post