Question

on python Here is a dictionary:   dictionary = { ' x ' : 55, ' y...

on python

Here is a dictionary:  

dictionary = { ' x ' : 55, ' y ' : 15, ' z ' : 35}

Write the code that will print all of the keys and values:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

dictionary = { ' x ' : 55, ' y ' : 15, ' z ' : 35}
keys = dictionary.keys()
values = dictionary.values()

print(keys)
print(values)

Output:

Add a comment
Know the answer?
Add Answer to:
on python Here is a dictionary:   dictionary = { ' x ' : 55, ' y...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3 Dn Ent Write a python program to create a Dictionary named grade with the given...

    3 Dn Ent Write a python program to create a Dictionary named grade with the given items and do the below operations: i. 15 i. Create Dictionary with keys-{'Monday', 'Tuesday', 'Wednesday Thursday', 'Friday') ii. values-{1, 2, 3, 4, 5) ii. Now append another item with key-'Saturday') and value-(63 to the already created Dictionary and print it.

  • python Define a function called print_values which takes a dictionary object as a parameter. The function...

    python Define a function called print_values which takes a dictionary object as a parameter. The function should print all values in the dictionary. However, the order is based on the sorted keys in the dictionary. For example, if we have the following dictionary: {'b':36, 'a':12, 'c':24} The output is: 12 36 24 A faulty solution has been provided below. Identify the fault and submit a corrected version of this code. def print_values(dict1): for k in list(dict1.keys()).sort(): print(dict1[k], end=" ") For...

  • in python Write a program that keeps a dictionary in which both keys and values are...

    in python Write a program that keeps a dictionary in which both keys and values are strings—names of students and their course grades. Prompt the user of the program to add or remove students, to modify grades, or to print all grades. The printout should be sorted by name and formatted like this: Carl: B- Joe: C Sarah: A Francine: A

  • they are 2 pictures attached 4) Delete set of keys from Python Dictionary Given: sampleDict =...

    they are 2 pictures attached 4) Delete set of keys from Python Dictionary Given: sampleDict = { "name": "Kelly", "age":25, "salary" : 8000, "city": "New york" } keysToRemove = ["name", "salary"] Expected output: {'city': 'New york', 'age': 25} 1) Write a Python program to iterate over dictionaries using for loops d = {'X': 10, y: 20, 'z': 30) 2) Write a Python program to get the maximum and minimum value in a dictionary my_dict = {'X':500, 'y':5874, 'z': 568} Sample...

  • For Python 3 MPLS please 1. Given a variable, unproved_conjectures, that is associated with a dictionary...

    For Python 3 MPLS please 1. Given a variable, unproved_conjectures, that is associated with a dictionary that maps the common names of mathematical conjectures to the years when the conjectures were made, write a statement that deletes the entry for "Fermat's Last Theorem". 2. Given a dictionary d, create a new dictionary that reverses the keys and values of d. Thus, the keys of d become the values of the new dictionary and the values of d become the keys...

  • Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys()...

    Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys() member function that returns a list of a dictionary's keys. You can check if a particular key is in a dictionary by using the in test with the keys list. For example, if our dictionary is MyDict = { 1: 'One', 2: 'Two', 3: 'Three' } Then ( 2 in MyDict.keys() ) evaluates to True, indicating that 2 is a valid key for MyDict....

  • Hi, I have this problem in Python : The email_list function receives a dictionary, which contains...

    Hi, I have this problem in Python : The email_list function receives a dictionary, which contains domain names as keys, and a list of users as values. Fill in the blanks to generate a list that contains complete email addresses (diana.prince@yahoo.com). The code : def email_list(domains): emails = [] for ___:    for user in users:      emails.___ return(emails) print(email_list({"yahoo.com": ["clark.kent", "diana.prince", "peter.parker"], "yahoo.com": ["barbara.gordon", "jean.grey"], "hotmail.com": ["bruce.wayne"]}))

  • using python Write a function that takes a dictionary and a list of keys as 2...

    using python Write a function that takes a dictionary and a list of keys as 2 parameters. It removes the entries associated with the keys from the given dictionary Your function should not print or return anything. The given dictionary should be modified after the function is called Note: it means that you can't create another dictionary in your function. Since dictionaries are mutable, you can modify them directly def remove_keys (dict, key_list) "" "Remove the key, value pair from...

  • Paperweight using Python 3 Create a dictionary named weight, initialised with the following values: "pencil": 10...

    Paperweight using Python 3 Create a dictionary named weight, initialised with the following values: "pencil": 10 "pen": 20 "paper": 4 "eraser": 80 Create another dictionary named available, initialised with the following values: "pen": 3 "pencil": 5 "eraser": 2 "paper": 10 If the weight dictionary gives the weight of an individual item of each type, and the available dictionary specifies the number of each item that is available, write code that determines the total weight of all available items (i.e. what...

  • PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold...

    PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold a dictionary or sets - must define a function that accepts dictionaries or sets as an argument A dictionary maps a set of objects (keys) to another set of objects (values). A Python dictionary is a mapping of unique keys to values. For e.g.: a dictionary defined as: released = { "iphone" : 2007, "iphone 3G": 2008, "iphone 3GS": 2009, "iphone 4" : 2010,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT