Q. Consider the following dictionary stateCapital:


stateCapital = {"AndhraPradesh":"Hyderabad","Bihar":"Patna","Maharashtra":"Mumbai", "Rajasthan":"Jaipur"}


Find the output of the following statements:


i. print(stateCapital.get("Bihar"))

ii. print(stateCapital.keys())

iii. print(stateCapital.values())

iv. print(stateCapital.items())

v. print(len(stateCapital))

vi print("Maharashtra" in stateCapital)

vii. print(stateCapital.get("Assam"))

viii. del stateCapital ["Andhra Pradesh"]

print(stateCapital)


Answer :-

i = Patna
ii =  dict_keys(['AndhraPradesh', 'Bihar', 'Maharashtra', 'Rajasthan'])
iii =  dict_values(['Hyderabad', 'Patna', 'Mumbai', 'Jaipur'])
iv =  dict_items([('AndhraPradesh', 'Hyderabad'), ('Bihar', 'Patna'), ('Maharashtra', 'Mumbai'), ('Rajasthan', 'Jaipur')])
v =  4
vi =  True
vii =  None
viii = error because of space between Andhra and Pradesh.


Post a Comment

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

Previous Post Next Post