Access over 20 million homework & study documents
search

A) Can a dictionary have two key with the same value Please answer

Content type

User Generated

Rating

Showing Page:
1/4
A) Can a dictionary have two key with the same value?
Please answer the rest as well Can a dictionary have two
keys with the same value? Two values with the same key?
Define a dictionary that maps month name abbreviations to
month names. Define a dictionary that maps the course
numbers of the courses you are currently taking to their
corresponding course titles. Define a dictionary that maps
the ISBN number of your textbooks to their tides. Given a
dictionary grade Counts - { \"A\'\': 8, \"D\": 3, \"B\": 15,
\"F\": 2, \"C\": 6} write the Python statement(s) to print: all
the keys. all the values. all the key and value pairs. all of
the key and value pairs in key order. The average value.
chart similar to the following in which each row contains a
key followed by a number of asterisks equal to the key\'s
data value. The rows should be printed in key order, as
shown below.
Solution
R8.11).
Yes, dictionary can have two key values same. But for
that key it will pick last defined;
Example-
dict = {\'1\': \'A\', \'2\': \'B\', \'2\': \'C\',\'4\',\'D\'}
print \"dict[\'2\']: \", dict[\'2\']

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
Output: dict[\'2\']: C
R8.12).
monthDict = {\'Jan\':\'January\',
\'Feb\':\'February\',\'Mar\':\'March\', \'Apr\':\'April\',
\'May\':\'May\',
\'Jun\':\'June\',\'Jul\':\'July\',\'Aug\':\'August\',\'Sep\':\'Septe
mber\',\'Oct\':\'October\',
\'Nov\':\'November\', \'Dec\':\'December\'}
R8.14).
courseDict = {\'CS101\': \'Algorithm\', \'CS102\':
\'Networking\', \'CS103\': \'Digital Electronics\',
\'CS104\':\'Automata Theory\',
\'CS105\':\'Mathematics\'}
R8.15).
gradeCounts = {\'A\':8,\'D\':3,\'B\':15, \'F\':2, \'C\':6}
a).
for key, value in gradeCounts.iteritems() :
print key
b).
for key, value in gradeCounts.iteritems() :

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now

Unformatted Attachment Preview

A) Can a dictionary have two key with the same value? Please answer the rest as well Can a dictionary have two keys with the same value? Two values with the same key? Define a dictionary that maps month name abbreviations to month names. Define a dictionary that maps the course numbers of the courses you are currently taking to their corresponding course titles. Define a dictionary that maps the ISBN number of your textbooks to their tides. Given a dictionary grade Counts - { \"A\'\': 8, \"D\": 3, \"B\": 15, \"F\": 2, \"C\": 6} write the Python statement(s) to print: all the keys. all the values. all the key and value pairs. all of the key and value pairs in key order. The average value. chart similar to the following in which each row cont ains a key followed by a number of asterisks equal to the key \'s data value. The rows should be printed in key order, as shown below. Solution R8.11). Yes, dictionary can have two key values same. But for that key it will pick last defined; Example- dict = {\'1\': \'A\', \'2\': \'B\', \'2\': \'C\',\'4\',\'D\'} print \"dict[\'2\']: \", dict[\'2\'] Output: dict[\'2\']: C R8.12). monthDict = {\'Jan\':\'January\', \'Feb\':\'February\',\'Mar\': ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Great! Studypool always delivers quality work.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4