Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.1, Problem 3CP
Suppose ' start' : 1472 is an element in a dictionary. What is the key? What is the value?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a dictionary (order_dict) that the key is the burger number, and the value is a list of the quantities.
For example: order_dict which is {'1': [10, 3, 78], '2': [35, 0, 65], '3': [9, 23, 0], '4': [0, 19, 43], '5': [43, 0, 21]}
Create a dictionary (total_order_dict) that the key is the burger number, and the value is the total of the quantities for that burger.
For example: total_order_dict which is {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64}
Use "assert to test the values of the total_order_dict
For example:
expected_result_ototal_order_dict = {'1': 91, '2': 100, '3': 32, '4': 62, '5': 64}
assert actual_result_ototal_order_dict['1'] == expected_result_ototal_order_dict['1'] , "The actual result is not the \same as expected result for the order number 1!"
(and test the other elements)
The function can be like:
def test_sum(): #Testing assert actual_result_ototal_order_dict['1'] == 91, "The actual result is not the \ same as expected result for the…
How do you create an empty dictionary?
The get(key) function for a dictionary will return _____ if the key does not exist. In python.
A. “
B. {}
C. “Null”
D. None 
Chapter 9 Solutions
Starting Out with Python (3rd Edition)
Ch. 9.1 - An element in a dictionary has two parts. What are...Ch. 9.1 - Which part of a dictionary element must be...Ch. 9.1 - Suppose ' start' : 1472 is an element in a...Ch. 9.1 - Suppose a dictionary named employee has been...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - Prob. 6CPCh. 9.1 - Suppose a dictionary named inventory exists. What...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - What will the following code display? stuff = {1 :...Ch. 9.1 - What is the difference between the dictionary...
Ch. 9.1 - Prob. 11CPCh. 9.1 - Prob. 12CPCh. 9.1 - What does the values method return?Ch. 9.2 - Prob. 14CPCh. 9.2 - Prob. 15CPCh. 9.2 - Prob. 16CPCh. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - Prob. 22CPCh. 9.2 - After the following statement executes, what...Ch. 9.2 - After the following statement executes, what...Ch. 9.2 - Prob. 25CPCh. 9.2 - Prob. 26CPCh. 9.2 - After the following code executes, what elements...Ch. 9.2 - Prob. 28CPCh. 9.2 - After the following code executes, what elements...Ch. 9.2 - After the following code executes, what elements...Ch. 9.2 - After the following code executes, what elements...Ch. 9.2 - Prob. 32CPCh. 9.3 - Prob. 33CPCh. 9.3 - When you open a file for the purpose of saving a...Ch. 9.3 - When you open a file for the purpose of retrieving...Ch. 9.3 - Prob. 36CPCh. 9.3 - Prob. 37CPCh. 9.3 - Prob. 38CPCh. 9 - You can use the __________ operator to determine...Ch. 9 - You use ________ to delete an element from a...Ch. 9 - The ________ function returns the number of...Ch. 9 - You can use_________ to create an empty...Ch. 9 - The _______ method returns a randomly selected...Ch. 9 - The __________ method returns the value associated...Ch. 9 - The __________ dictionary method returns the value...Ch. 9 - The ________ method returns all of a dictionary's...Ch. 9 - The following function returns the number of...Ch. 9 - Prob. 10MCCh. 9 - Prob. 11MCCh. 9 - This set method removes an element, but does not...Ch. 9 - Prob. 13MCCh. 9 - Prob. 14MCCh. 9 - This operator can be used to find the difference...Ch. 9 - Prob. 16MCCh. 9 - Prob. 17MCCh. 9 - The keys in a dictionary must be mutable objects.Ch. 9 - Dictionaries are not sequences.Ch. 9 - Prob. 3TFCh. 9 - Prob. 4TFCh. 9 - The dictionary method popitem does not raise an...Ch. 9 - The following statement creates an empty...Ch. 9 - Prob. 7TFCh. 9 - Prob. 8TFCh. 9 - Prob. 9TFCh. 9 - Prob. 10TFCh. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? dct =...Ch. 9 - What will the following code display? stuff =...Ch. 9 - How do you delete an element from a dictionary?Ch. 9 - How do you determine the number of elements that...Ch. 9 - Prob. 7SACh. 9 - What values will the following code display? (Dont...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - After the following statement executes, what...Ch. 9 - What will the following code display? myset =...Ch. 9 - After the following code executes, what elements...Ch. 9 - Prob. 16SACh. 9 - Prob. 17SACh. 9 - Prob. 18SACh. 9 - After the following code executes, what elements...Ch. 9 - Prob. 20SACh. 9 - Write a statement that creates a dictionary...Ch. 9 - Write a statement that creates an empty...Ch. 9 - Assume the variable dct references a dictionary....Ch. 9 - Assume the variable dct references a dictionary....Ch. 9 - Prob. 5AWCh. 9 - Prob. 6AWCh. 9 - Prob. 7AWCh. 9 - Prob. 8AWCh. 9 - Prob. 9AWCh. 9 - Prob. 10AWCh. 9 - Assume the variable dct references a dictionary....Ch. 9 - Write code that retrieves and unpickles the...Ch. 9 - Course information Write a program that creates a...Ch. 9 - Capital Quiz The Capital Quiz Problem Write a...Ch. 9 - File Encryption and Decryption Write a program...Ch. 9 - Unique Words Write a program that opens a...Ch. 9 - Prob. 5PECh. 9 - File Analysis Write a program that reads the...Ch. 9 - World Series Winners In this chapters source code...Ch. 9 - Name and Email Addresses Write a program that...Ch. 9 - Blackjack Simulation Previously in this chapter...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- How can you determine whether a key-value pair exists in a dictionary?arrow_forwarddef city_dict(adict): """ Question 6 -Given a dictionary that maps a person to a list of countries they want to travel to, return a dictionary with the value being the list sorted by the last letter in each countries name. If two countries have the same last letter, sort by the first letter. -For an extra challenge, try doing this in one line (Optional). Args: adict (dict) Returns: dict >>> city_dict({"Pablo": ["Belgium", "Canada", "Germany"], "Athena": ["Italy", "France", "Egypt"], "Liv": ["Japan", "Bolivia", "Greece"]}) {'Pablo': ['Canada', 'Belgium', 'Germany'], 'Athena': ['France', 'Egypt', 'Italy'], 'Liv': ['Bolivia', 'Greece', 'Japan']} >>> city_dict({"Jacob": ["Bahamas", "Brazil", "Chile"], "Lexi": ["Colombia", "Finland", "Panama"], "Emily": ["Ireland", "Russia", "Kenya", "Jordan"]}) {'Jacob': ['Chile', 'Brazil', 'Bahamas'], 'Lexi': ['Colombia', 'Panama', 'Finland'], 'Emily': ['Kenya',…arrow_forwardWrite code that iterates through a dictionary represented by the variable my_dict and prints any values (not keys!) associated with keys beginning with the letter "k" (lowercase).arrow_forward
- How can you copy the entire dictionary to a new dictionary?arrow_forwarddef add_key_values(x: str)-> dict[str, int]: "Return a dictionary where the keys are the distinct characters appearing in x and the values are how many times they appear." Starting from the top and considering each testcase in turn, please mark the 6 options that add nothing to what was covered by the previous tests. x = "", return: {} x = "a", return {"a":1} x="ab", return {["a": 1, "b":1} x = "aab", return {"a": 2, "b": 1} x = "1233", return: {"1": 1, "2": 1, "3":2} x = "1223334444", return: {"1": 1, "2": 2, "3": 3, "4":4} x = "cabba", return: {"c": 1, "a": 2, "b":2} x = "qnwhnwq", return: {"q": 2, "n": 2, "w": 2, "h": 1} x = "a,aa33b", return {"a": 3, ",": 1, "3": 2, "b":1} x = "midterm", return {"m": 2, "i": 1, "d": 1, "t": 1, "e": 1, "r": 1} x = "csc108ishard", return {"c": 2, "s": 2, "1": 1, "0": 1, "8: 1, "i": 1, "h": 1, "a": 1, "": 1, "d":1}arrow_forwardThis is my code for a dictionary of student's test scores. def main(): #Create a dictionary with name as key #Marks as the list of values student_dictionary = \ { 'Brian': [94, 89, 92], 'Rachel': [100,90,65], 'Jon': [67.5,95,100], 'Brit': [0,78,80] , 'Gret': [65,100,78], 'Andrea': [55.5,67,79] } for key in student_dictionary.keys(): print('Name: ', key, " , Marks:", student_dictionary.get(key)) if __name__ == '__main__': main() Problem: Find and print out Rachels second score (should be a 90)arrow_forward
- Create a static dictionary with a number of users and with the following values: First name Last name Email address Password Ask the user for: 5. Email address 6. Password Loop (for()) through the dictionary and if (if()) the user is found print the following: 7. Hello, first name last name you have successfully logged in 8. Notify the user if the password and email address are wrong 9. Additional challenge: if you want the program to keep asking for a username and password when the combination is wrong, you will need a while() loop. 10. Save the file as assignment03yourlastname.pyarrow_forwardTo create a dictionary, you just surround a sequence of value pairs of separated by: and the pair separated by commas, within curly braces. True or false? arrow_forwardIf you are given the following dictionary: dict_1 = { 'Dallas': 'Cowboys', Green Bay': 'Packers New England': 'Patriots', Philadelphia': 'Eagles', Seattle': Seahawks } And you want to add a key value pairing for "New Orleans" : "Saints", what is the code you would use? add(dict_1["New Orleans": "Saints"]) dict_1["New Orleans"] = "Saints" In order to add another key value pairing, you would have to edit the original "dict_1" dictionary directly dict 1 New Orleans} == dict_1{Saints} > add("New Orleans" : "Saints"]_____ 00arrow_forward
- Create a new dictionary called prices_stocks using {} format like the example below. prices_stocks={} Put these values in your prices_stocks dictionary: "banana": [4,5] "apple": [2,2] "orange": [1.5,2.5] "pear": [3,4] So the key of dictionary is name of item and value is a list (first element of that list is stock and second element is relevant price) Loop through each key in prices_stocks, for each key, print out the key along with its price and stock information. Finally calculate how much you earn if you sold all of your products. Print the answer in the following format:arrow_forwardHow many elements (2, 3, 0, or Can't say - an error message was issued) are in the dictionary someData after the following code has been executed? someData = { } someData['cheese'] = 'dairy' someData['Cheese'] = 'dairy' someData['Cheese'] = 'Dairy' someData['cheese'] = 'Dairy'arrow_forwardOverview This is a review assignment where you will use multiple tools you have picked up so far throughout the course. If you're confused about how to do something make sure you look back at earlier assignments. In this program you will start by declaring an empty dictionary named population_dict. Then you will use a while-loop to prompt a user for a series of cities and their populations, storing the input in population_dict). After this you will prompt the user to decide what is the maximum population for a city to be considers a small down. Finally, you will open a file called populationdata.txt where you will write the results. Expected Output Example of standard out (the console): What is next city? (enter q to quit) Long Beach What is the population of Long Beach? 362000 What is next city? (enter q to quit) Los Angeles What is the population of Los Angeles? 382000000 What is next city? (enter q to quit) San Diego What is the population of San Diego? 136000000 What is next city?…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Dictionaries - Introduction to Data Structures (Episode 8); Author: NullPointer Exception;https://www.youtube.com/watch?v=j0cPnbtp1_w;License: Standard YouTube License, CC-BY