Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 9, Problem 12MC
This set method removes an element, but does not raise an exception if the element is not found.
a. remove
b. discard
c. delete
d. erase
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule03:50
Students have asked these similar questions
Sets store their elements in an unordered fashion.True or False
The elements in the set cannot be accessed using indexing and slicing, choose whether this statement is true or false.
a.
True
b.
False
Clear my choice
Phyton:
Program 6:
Write a program that allows the user to add data from files or by hand. The user may add more data whenever they want. The print also allows the user to display the data and to print the statistics. The data is store in a list. It’s easier if you make the list global so that other functions can access it.
You should have the following functions:
· add_from_file() – prompts the user for a file and add the data from it.
· add_by_hand() – prompts the user to enter data until user type a negative number.
· print_stats() – print the stats (min, max, mean, sum). You may use the built-in functions.
Handling errors such as whether the input file exist is extra credit.
To print a 10-column table, you can use the code below:
for i in range(len(data)):
print(f"{data[i]:3}", end="")
if (i+1)%10==0:
print()
print()
Sample run:
Choose an action
1) add data from a file
2) add data by hand
3) print stats
4)…
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
Payroll Class Design a PayRoll class that has data members for an employees hourly pay rate, number of hours wo...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Summarize the booting process.
Computer Science: An Overview (12th Edition)
The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall t...
Computer Systems: A Programmer's Perspective (3rd Edition)
A class that is not intended to be instantiated, but used only as a base class, is called a(n) __________. a. d...
Starting out with Visual C# (4th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
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_forwardpython exercise: Write a Python function called calculate_average that takes a list of numbers as input and returns the average of the numbers in the list. If the input list is empty, the function should raise an EmptyListError exception. Handle the case where the input list is empty by raising a custom EmptyListError exception. This exception should have an error message that says "Cannot calculate average of an empty list".arrow_forwardDoes a set allow you to store duplicate elements?arrow_forward
- This will happen if you try to use an index that is out of range for a list.a. A ValueError exception will occur.b. An IndexError exception will occur.c. The list will be erased and the program will continue to run.d. Nothing—the invalid index will be ignored.arrow_forwardTrue or False: Arrays can have new elements added to it without resizingarrow_forwarddef delete_item(...): """ param: info_list - a list from which to remove an item param: idx (str) - a string that is expected to contain an integer index of an item in the in_list param: start_idx (int) - an expected starting value for idx (default is 0); gets subtracted from idx for 0-based indexing The function first checks if info_list is empty. The function then calls is_valid_index() to verify that the provided index idx is a valid positive index that can access an element from info_list. On success, the function saves the item from info_list and returns it after it is deleted from info_list. returns: If info_list is empty, return 0. If is_valid_index() returns False, return -1. Otherwise, on success, the function returns the element that was just removed from info_list. Helper functions: - is_valid_index() """arrow_forward
- 2. ID: A Name: 2. A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding value. The following procedure is intended to return true if numberList is increasing and return false otherwise. Assume that numberList contains at least two elements. Line 1: PROCEDURE isIncreasing (numberList) Line 2: { Line 3: count 2 Line 4: REPEAT UNTIL(count > LENGTH(numberList)) Line 5: Line 6: IF(numberList[count] =. YA198ICarrow_forwardOCaml Code: Attached are the instructions. Make sure to read the instructions carefully and write your own test cases to make sure the code works. Make sure to include a screenshot of the correct code with the test cases that is used along with the output of the code being passed.arrow_forwardI need this now please help me out.arrow_forward
- Array Elements = 50, 60, 70, 80, 90, 100Search each elementSearch for index 7: Output should be out of bound exceptionUSE JAVA PROGRAMMINGarrow_forwardHomework Assignment-1Topics: Functions, Dictionary, ImportProblem description: Write a python application to simulate an online clothing system. Thepurpose of this assignment is to gain experience in Python dictionary structure, create basicPython functions and import a module.Design solution: The template file contains a list of clothes item sold, each item in the listcontains the item id, name of the item and the prices. The program will generate an items_dictwhere each key is the item id of the cloth and the values will be a list of item name and priceinformation. A customer will be presented with a main menu with 4 different options: displayall items, add an item to cart, checkout and exit the program. A customer can buy an item byentering the ID of the item. This program implements a dictionary called cart, where each key isthe item id and the values are the list of name, price and quantity that user chooses topurchase. The program keeps repeating by displaying the main menu to…arrow_forwardIf the following is a pointer based list, give the correct commands that change the list from BEFORE to AFTER. BEFORE Plane Bike Pickup Caddy Truck Motorbike Van Ship AFTER Plane Bike Caddy Truck Motorbike Van Scooter Ship Select one: A.insert (5, "Scooter"); delete ("Pickup") B.insert (6, "Scooter"); delete ("Pickup") C.delete ("Scooter"); insert(2, "Pickup") D.delete ("Pickup"); insert (6, "Scooter")arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher: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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Linux - Tutorial for Beginners in 13 MINUTES! [ UPDATED ]; Author: bai;https://www.youtube.com/watch?v=BMGixkvJ-6w;License: Standard YouTube License, CC-BY
What is Linux?; Author: Techquickie;https://www.youtube.com/watch?v=zA3vmx0GaO8;License: Standard YouTube License, CC-BY
Introduction to Linux and Basic Linux Commands for Beginners; Author: sakitech;https://www.youtube.com/watch?v=IVquJh3DXUA;License: Standard Youtube License