PYTHON ASSIGNMENT 6: DICTIONARIES



Write a program to generate a dictionary called phonebook containing the list of customers and their telephone numbers.
Lookup: Read a customer name and print the associated entry from the phonebook on a new line in the form name=phonenumber; If an entry for name is not found, print “Not found" instead.
Reverse Lookup: Given a phone number find the customer details. If number is not present, print “No match found”

Create a dictionary containing employee name and id (name:id). Display
Employee names, sorted in alphabetical order
Employee name and id, sorted alphabetically by name
Inverse the dictionary (id : name)

Consider two lists
NAMES = [’Alice’, ’Bob’, ’Cathy’, ’Dan’, ’Ed’, ’Frank’, ’Gary’, ’Helen’, ’Irene’, ’Jack’, ’Kelly’, ’Larry’]
AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19]
These lists match up, so Alice’s age is 20, Bob’s age is 21, and so on. Write a program that
Combines these lists into a dictionary.
Reads a name and returns the age.
Reads an age and returns the names of all the people who are that age.

Histogram: Read a string and create a dictionary containing the frequency of the characters in string.

Histogram: Read a string and create a dictionary containing the frequency of the words in string.

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu