Computer Science, asked by raghdevansh4418, 11 months ago

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 Anonymous
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