Computer Science
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.
Related Questions
Find the output of the following:
word = 'work hard' result = word.find('work') print("Substring, 'work', found at index:", result) result = word.find('har') print("Substring, 'har ' ,found at index:", result) if (word.find('pawan') != -1): print("Contains given substring ") else: print("Doesn't contain given substring")Consider the following string mySubject:
mySubject = "Computer Science"What will be the output of the following string operations?
(i) print (mySubject [0:len(mySubject)])
(ii) print (mySubject[-7:-1])
(iii) print (mySubject[::2])
(iv) print (mySubject [len (mySubject) -1])
(v) print (2*mySubject)
(vi) print (mySubject[::-2])
(vii) print (mySubject[:3] + mySubject[3:])
(viii) print (mySubject.swapcase() )
(ix) print (mySubject.startswith('Comp') )
(x) print (mySubject.isalpha() )
Consider the string str1 = "Global Warming".
Write statements in Python to implement the following:
(a) To display the last four characters.
(b) To replace all the occurrences of letter 'a' in the string with "*".
What will be the output of the following code?
Text = "Mind@Work!" ln = len(Text) nText = "" for i in range(0, ln): if Text[i].isupper(): nText = nText + Text[i].lower() elif Text[i].isalpha(): nText = nText + Text[i].upper() else: nText = nText + 'A' print(nText)