Computer Science
Consider the dictionary stateCapital:
stateCapital = {"AndhraPradesh" : "Hyderabad",
"Bihar" : "Patna",
"Maharashtra" : "Mumbai",
"Rajasthan" : "Jaipur"}
Find the output of the following statements:
print(stateCapital.get("Bihar"))print(stateCapital.keys())print(stateCapital.values())print(stateCapital.items())
Python Dictionaries
4 Likes
Answer
Patnadict_keys(['AndhraPradesh', 'Bihar', 'Maharashtra', 'Rajasthan'])dict_values(['Hyderabad', 'Patna', 'Mumbai', 'Jaipur'])dict_items([('AndhraPradesh', 'Hyderabad'), ('Bihar', 'Patna'), ('Maharashtra', 'Mumbai'), ('Rajasthan', 'Jaipur')])
Answered By
1 Like
Related Questions
Differentiate between append() and extend() methods and provide examples of each.
Consider the string
mySubject:mySubject = "Computer Science"What will be the output of:
print(mySubject[:3])print(mySubject[-5:-1])print(mySubject[::-1])print(mySubject*2)
What are the ways by which websites track us?
What is IPR infringement and what are the forms of IPR infringement?