Q. Consider the following string myAddress:
myAddress = "WZ-1,New Ganga Nagar,New Delhi"
What will be the output of following string operations :
i. print(myAddress.lower())
ii. print(myAddress.upper())
iii. print(myAddress.count('New'))
iv. print(myAddress.find('New'))
v. print(myAddress.rfind('New'))
vi. print(myAddress.split(','))
vii. print(myAddress.split(' '))
viii. print(myAddress.replace('New','Old'))
ix. print(myAddress.partition(','))
x. print(myAddress.index('Agra'))
Answer:-
i = wz-1,new ganga nagar,new delhi
ii = WZ-1,NEW GANGA NAGAR,NEW DELHI
iii = 2
iv = 5
v = 21
vi = ['WZ-1', 'New Ganga Nagar', 'New Delhi']
vii = ['WZ-1,New', 'Ganga', 'Nagar,New', 'Delhi']
viii = WZ-1,Old Ganga Nagar,Old Delhi
xi = ('WZ-1', ',', 'New Ganga Nagar,New Delhi')
x = error because Agra is not present in myAddress
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )