Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 9.2, Problem 25CP
Program Plan Intro
Set “remove()” method:
- • The “remove()” method is used to remove an item from the set.
- • The argument that passed into the “remove()” method will be removed from the set.
Set “discard()” method:
- • The “discard()” method is also used to remove an item from the set.
- • The argument that passed into the “discard()” method will be removed from the set.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
How well do variables work for handling data lists? What do you think is going on?
12. You have written a sorting method that takes an array of Object as its
parameter. What limitations are imposed on the users of this method?
How can you examine the current status of an ArrayList to determine how well it is working?
Chapter 9 Solutions
Starting Out with Python (4th 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...Ch. 9 - Word Index Write a program that reads the contents...
Knowledge Booster
Similar questions
- of range. 3. Use the method swap that you wrote in Exercise 2 to write a method that reverses the order of the items in a list alist.arrow_forwardFrom the code supplied by the tutor, modify it so that: 1. Ask what kind of animal it is (for example, carnivore, herbivore, and omnivore) When prompting for the information, it is saved in a list for each of the three animal types (for example, lions in carnivores, bears in omnivores, giraffes in herbivores) and they are saved depending on the number that the user adds in each list. 2. At the end, a list of lists is printed that presents the data of each of the saved animals according to their type.arrow_forwardLoad your bag with some initial values, but do not fill it. Your client code should give the user the option to: display the contents of the bag using the class method “toVector” add values to the bag remove values from the bag sort the bag search for a value using their choice of either the iterative search or the recursive search - both need to be tested Allow the user to keep doing these things until they are done. Do not automatically sort the bag if the user chooses to search. Your program should give the user a message telling them they must first sort the bag before they can search.You decide what the user interface will be. Make it clear and easy to use. It can be very basic; nothing fancy. A menu driven program works well. Each value in your array should be unique - no value will appear in the array multiple times. Your array elements can be any data type – use a template class put in place in the code provided. You can write your client code to process a bag holding any…arrow_forward
- Write the definition of a method reverse, whose parameter is an array of chars. The method reverses the elements of the array. The method does not return a value.arrow_forwardScrabble Help: The file dictionary.txt contains all of the words in the Official Scrabble Player's Dictionary, Second Edition. Note: this list contains some offensive language. Write a class, WordLists, in Java that generates useful word lists for scrabble players using this list. Your class should contain the following methods: WordLists(String fileName): a constructor that takes the name of the dictionary file as the only parameter. lengthN(int n): returns an ArrayList of all length n words (Strings) in the dictionary file. endsWith(char lastLetter, int n): returns an ArrayList of words of length n ending with the letter lastLetter containsLetter(char included, int index, int n): returns an ArrayList of words of length n containing the letter included at position index. So for example the word "cannon" would be on the list returned by containsLetter('o',6,4) because it contains the letter 'o', at index 4, and is length 6. multiLetter(int m, char included): returns an ArrayList of…arrow_forward4. Now examine the ArrayList methods in the above table, a) Which method retrieves elements from the ArrayList? b) Which method replaces the value of an element that already exists in the ArrayList? c) Which two methods initializes the value of an element? d) How do the two methods in (c) differ? Which method(s) would be appropriate in the above Java program (after we convert it to work with ArrayLists)?arrow_forward
- In C++, first, make a set with 10 objects, then ask the user to enter a value for search in your list. if the value exists then print "the value you are looking for that is in the set", otherwise print "The value you are looking for that is not in the list".arrow_forwardaddCourse: accepts an object of type Course as the first parameter and the idNum of the Student as the second parameter. The Course can be added only if the Student object with the specified idNum exists in the studentsList, Course does not exist in the coursesRegistered list for the Student, After adding the course, the number of credits, do not exceed 18. If the course is added successfully, return true, else return false.arrow_forwardWrite a method (function) that called To_do List () and this function displays a menu of operations as shown in the sample Operations: Add Item. View Items. Delete Items and Evit. From the prouram Run your program and display a list of these operators then ask the user to enter the mumber of operation (method) You can enter 1, 2, 3, or 4 for choosing Add, View or Delete and Exit Descriptions: For add operation you need to insert items into a list, also you need to sorting the items inside the list. For view operation you neod to display the items that has been add before For delete operation, you need to delete according to the item that user has been select. Ex: if you want to delete the second item, the program should ask you which item you need to delete, and you will select the second item then deleted form the list Your program should be inside a while loop and exit koop whenever you Enter 4 (Exit operation) Methods 1. Add Item 2. View Items 3. Delete hem 4. Exit Choose an…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning