Question

In: Computer Science

Using Python, write a program named hw3a.py that meets the following requirements: Create a dictionary called...

Using Python, write a program named hw3a.py that meets the following requirements:

  1. Create a dictionary called glossary.
  2. Have the glossary include a list of five (5) programing words you have learned in chapters 4-6. Use these words as keys to your dictionary.
  3. Find the definition of these words and use them as the values to the keys.
  4. Using a loop, print each word and its meaning as neatly formatted output.
  5. Create three dictionaries called person.
  6. Have each of the person dictionaries represent a different person. Each dictionary should store a person's information to include their:
    1. first name
    2. last name
    3. age
    4. city
  7. Use the append() method to store all three dictionaries in a list called people.
  8. Use a loop to go through each item in the list of people.
  9. As you loop, print everything you have stored about each person in neatly formatted output.
  10. Comment the code by the appropriate requirement as shown in previous assignments.


Lists, Tuples, Statements, Loops, Dictionary, Nesting

Solutions

Expert Solution

#creating the Dictionary with name glossary
glossary =   {
"List": "List is a collection which is ordered and changeable Allows duplicate members",
"Dictionary":" is a collection which is unordered, changeable and indexed. No duplicate members",
"set":"Set is a collection which is unordered and unindexed. No duplicate members.",
"and":"The and keyword is a logical operator, and is used to combine conditional statements",
"or":"The or keyword is a logical operator, and is used to combine conditional statements:"
}
for x in glossary:#Print all keys and values in the dictionary, one by one:
print(x,"=",glossary[x])


# Empty list
people=[]
Person= { 'Person1': { }, # nested dictionary
         'Person2': { },
        'Person3':{ }}

# Nested dictionary having same keys
Person= { 'Person1': {'firs tname': 'siva','last name':'ram', 'age': '19','city':'Hyderabad'},
         'Person2':{'firs tname': 'harbajan','last name':'singh', 'age': '29','city':'vizag'},
         'Person3':{'firs tname': 'sai','last name':'kumar', 'age': '16','city':'Delhi'}}

people.append(Person)#appeding to list

          
for x in Person:#Print all keys and values in the dictionary, one by one:
print(x,"=",Person[x])


Related Solutions

Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to...
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to Zion's Pizza Restaurant and ask the user how many people are in their dinner group. If the answer is more than eight (8), print a message saying they'll have to wait for a table. Otherwise, report that their table is ready and take their order. Assume the client orders one pizza, and ask what he/she would like on their pizza, include a loop that...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and fill it with the names of various sandwiches. Make an empty list called finished_sandwiches. Loop through the list of sandwich orders and spring a message for each order such as "I am working on your tuna sandwich" As each sandwich is made, move it to the list of finished sandwiches. After all the sandwiches have been made, print a message listing each sandwich that...
Write a python program using the following requirements: Create a class called Sentence which has a...
Write a python program using the following requirements: Create a class called Sentence which has a constructor that takes a sentence string as input. The default value for the constructor should be an empty string The sentence must be a private attribute in the class contains the following class methods: get_all_words — Returns all the words in the sentence as a list get_word — Returns only the word at a particular index in the sentence Arguments: index set_word — Changes...
Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate...
Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate the key 'class_name' with the value 'MAT123', and associate the key 'sect_num' with '211_145'
1. Write a Java program from scratch that meets the following requirements: a. The program is...
1. Write a Java program from scratch that meets the following requirements: a. The program is in a file called Duplicates.java that defines a class called Duplicates (upper/lower case matters) b. The program includes a Java method called noDuplicates that takes an array of integers and returns true if all the integers in that array are distinct (i.e., no duplicates). Otherwise it returns false. Make sure the method is public static. example tests: noDuplicates({}) returns true noDuplicates({-1, 1}) returns true...
Write a C program that meets the following requirements. Uses a while loop to display the...
Write a C program that meets the following requirements. Uses a while loop to display the first 10 natural numbers (on one row, with a tab separating each number) Uses a while loop to find the sum of the second set of 10 natural numbers. Reads a user entry and displays all the natural numbers up to the user entry (on a column list with a new line separating each number). Finds and displays the sum of all natural numbers...
PYTHON PROGRAM Requirements: 1. Create an empty directory a variable named song_search 2. Repeatedly prompt the...
PYTHON PROGRAM Requirements: 1. Create an empty directory a variable named song_search 2. Repeatedly prompt the user to enter either the title of a song or enter nothing if they have no more songs to enter 3. For each song title entered by the user, split the song title into words by using the split function and splitting on a space. For each word from each song title, ensure the song_search dictionary has a entry with that word as the...
*Python* 1.1) Create an empty dictionary called 'addresses'. The dictionary you just created will map names...
*Python* 1.1) Create an empty dictionary called 'addresses'. The dictionary you just created will map names to addresses. A person's name (stored as a string) will be the KEY and that person's address (stored as a string) will be the VALUE. 1.2) Insert into the dictionary 'addresses' the names and addresses of two (possibly imaginary) friends of yours. 1.3) Create a second empty dictionary called 'ages'. The dictionary you just created will map names to ages. A person's name (stored...
Using python. 1. How to create a dictionary that has an integer as a key and...
Using python. 1. How to create a dictionary that has an integer as a key and a byte as a value? the dictionary keys must contain integers from 0 to 255. It should be similar to UTF-8. When we enter an integer, it should return 1 byte. 2. Create a function when a user gives 1 byte, it should return the key from the previous dictionary.
USING PYTHON Write a program to create a number list. It will call a function to...
USING PYTHON Write a program to create a number list. It will call a function to calculate the average values in the list. Define main ():                        Declare variables and initialize them                        Create a list containing numbers (int/float)                        Call get_avg function that will return the calculated average values in the list.                                       Use a for loop to loop through the values in the list and calculate avg                        End main()
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT