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, Problem 7MC
The __________ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value.
a. pop ()
b. key ()
c. value ()
d. get ()
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
*python coding please
This exercise assumes that you have created the Employee class for Programming Question 1.Create a program that stores Employee objects in a dictionary. Use the employee ID numberas the key. The program should present a menu that lets the user perform the following actions:• Look up an employee in the dictionary• Add a new employee to the dictionary• Change an existing employee’s name, department, and job title in the dictionary• Delete an employee from the dictionary• Quit the programWhen the program ends, it should pickle the dictionary and save it to a file. Each time theprogram starts, it should try to load the pickled dictionary from the file. If the file does notexist, the program should start with an empty dictionary
import are as are# A dictionary for the simplified dragon text game# The dictionary links a room to other rooms.rooms = {'Great Hall': {'South': 'Bedroom'},'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'},'Cellar': {'West': 'Bedroom'}}location = 'Great Hall' # set starting room# Based on the start room (a key), what is the corresponding dictionary value?print("\n", rooms[location])# Available directionsprint(rooms[location].keys())print(*rooms[location].keys())# Available roomsprint(rooms[location].values())print(*rooms[location].values())direction = ['South', 'North', 'East', 'West']# game loopwhile direction != "exit":print('\nYou are in the',location)possible_moves = rooms[location].keys()print('possible moves', *possible_moves)direction = input("Which direction should I go?").strip().lower()print('You chose to go:', direction)I am supposed to make a program to be able to move from room to room in python, and exit, how do I finish this is as far as I have completed
Name SearchIn the Chap07 folder of the Student Sample Programs, you will find the followingfiles:• GirlNames.txt—This file contains a list of the 200 most popular names given to girls born in the United States from 2000 through 2009.• BoyNames.txt—This file contains a list of the 200 most popular names given to boys born in the United States from 2000 through 2009.Create an application that reads the contents of the two files into two separatearrays or Lists. The user should be able to enter a boy’s name, a girl’s name, orboth, and the application should display messages indicating whether the nameswere among the most popular
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What are the design issues for character string types?
Concepts of Programming Languages (11th Edition)
Define each of the following terms: determinant functional dependency transitive dependency recursive foreign k...
Modern Database Management
The following C++ program will not compile because the lines have been mixed up. cout Success\n; cout Success...
Starting Out with C++ from Control Structures to Objects (9th Edition)
When a selector name starts with a period in a JavaFX CSS style definition, it means the selector corresponds t...
Starting Out with Java: Early Objects (6th Edition)
Computers process data under the control of sets of instructions called
Java How To Program (Early Objects)
Are reflex actions (such as flinching from a hot stove) rational? Are they intelligent?
Artificial Intelligence: A Modern Approach
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
- State True/False: A set may contain a specific value more than once, however, only unique value will be stored. True Falsearrow_forwardTrus or false: The back_inserter iterator always causes the new elements to be inserted following the existing ones.arrow_forwardkeys = ['name', 'last', 'job_title', 'email']Faculty2 = Faculty = dict.fromkeys(keys)print(Faculty2) Use the dictionaries that you created for faculty members. Be sure that all the dictionaries have the same keys: name, last name, etc. If there are keys or values missing, add them. If you do not have the value, you can use 'n/a' or 'TBD'. Make a list of the dictionaries. Loop the list to print all the information available to each faculty member. In Python lang please.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_forwarddef create_scrabble (user_input): tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 } point = 0 for i in range(len(word)): for key,value in tile_dict.items(): if key == word[i]: point += value print(point) if __name__ == "__main__": word = input().upper() create_scrabble(word) Some error in your code, python error looks like name 'word' is not defined, please explore it in developer mode (do not forget to call the function!)arrow_forwardComment block: Set up comments using the standard format in a <# and #> container, which should contain a synopsis, description, and at least one example which shows how to run the script. Set up an array: Put values in the array $ComputerNames, containing the names of two computers: DC1 and W10-CLIENT. Prompt for user's name: Use the text Please enter your first name, store the value the user will provide in a variable named $FirstName, and write out the text Hello followed by a space, followed by the name entered. Prompt for report type, and store value provided: Ask the user to enter AD if the information on Active Directory Users is required, and WMI for Windows Machine Instrumentation. Store the answer provided in variable $ReportType Confirm report selection: If an Active Directory report was requested, on a new line print the message "A list of all AD users was requested for computers " followed by the contents of the $ComputerNames array. If a Windows Machine…arrow_forward
- Code the following directions in python: 1.Write a statement that creates a dictionary containing the following key-value pairs: 'a' : 1 'b' : 2 'c' : 3 2.Write a statement that creates an empty dictionary. 3.Assume the variable dct references a dictionary. Write an if statement that determines whether the key 'James' exists in the dictionary. If so, display the value that is associated with that key. If the key is not in the dictionary, display a message indicating so.arrow_forwardIn Python, grades_dict = {'Wally': [87,96,70], 'Eva': [100,87,90], 'Sam': [94,77,90], 'Katie': [100,81,82], 'Bob': [83, 65, 85]} Ask user to enter the names of the rows, i.e., indices. You can use: len(grades) to get the number of rows of the DataFrame. In addition, using the sort_index() method, ask user whether they wish to sort by rows or by columns and whether to sort in ascending or descending order (do not use any if-else statements)arrow_forwardswitch_player(): we will allow the players to choose their own names, but for our purposes, it is easier to think of them as number (0 and 1, for indexing purposes). We will display their names to them on the screen, but in the background, we will keep track of them based on their number. This function should take 1 argument, an integer (either 0 or 1) representing the player and should return the opposite integer (1 if 0 is entered and 0 if 1 is entered). This is a simple function, but it will make our code cleaner later. Use your constants! Using Thonnyarrow_forward
- A(n) __________ is an object that can hold a group of values that are all of the same data type. a. array b. collectionc. container d. setarrow_forwardnumbers = [2, 4, 5, 8] user_input = input () while user_input != 'end': try: #Possible ValueError divisorint (user_input) if divisor > 20: #Possible NameError #compute () is not defined result = compute (result) elif divisor < 0: #Possible IndexError result = numbers [divisor] else: # Possible ZeroDivisionError result = 20 // divisor print (result, end='.') except (ValueError, ZeroDivisionError): print ('r', end=' ') except (NameError, IndexError): print ('s', end=' ') Type the program's output user_input = input () print ('OK') # // truncates to an integer Input -3 three 67 0 10 -8 end Outputarrow_forwardBlock elements are normally displayed without starting a new line. * False O Truearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Dictionaries - Introduction to Data Structures (Episode 8); Author: NullPointer Exception;https://www.youtube.com/watch?v=j0cPnbtp1_w;License: Standard YouTube License, CC-BY