Consider the string str="Global Warming" Write statements in Python to implement the following
(a) To display the last four characters.
(b) To display the substring starting from index 4 and ending at index 8.
(c) To check whether string has alphanu-meric characters or not
(d) To trim the last four characters from the string.
(e) To trim the first four characters from the string.
(f) To display the starting index for the substring „ WaD.
(g) To change the case of the given string.
(h) To check if the string is in title case.
(i) To replace all the occurrences of letter „aD in the string with „*?
Answers
Answered by
10
The python statements are -
(a) print str[-4:]
(b) print str[4:8]
(c) str.isalnum( )
(d) str[:-4]
(de str[:+4]
(g) str.swapcase( )
(h) str.istitle( )
(i) str.replace(‘a’,’*’)
The output of the said program is -
>>>
ming
Al W
False
Global Warming
7
gLOBAL WARMING
True
Glob*1 W*rming
>>>
Similar questions
Math,
5 months ago
Math,
5 months ago
Math,
5 months ago
Computer Science,
9 months ago
Computer Science,
9 months ago
Math,
1 year ago