in python. Please include docstring, so I can understand each step to this program. Thanks.
you will import the json module.
Write a class named NeighborhoodPets that has methods for adding a pet, deleting a pet, searching for the owner of a pet, saving data to a JSON file, loading data from a JSON file, and getting a set of all pet species. It will only be loading JSON files that it has previously created, so the internal organization of the data is up to you.
- The init method takes no parameters and initializes all the data members, which must all be private.
- The add_pet method takes as parameters the name of the pet, the species of the pet, and the name of the pet's owner. If a pet has the same name as a pet that has already been added, then the function should raise a DuplicateNameError (you'll need to define this exception class).
- The delete_pet method takes as a parameter the name of the pet and deletes that pet.
- The get_owner method takes as a parameter the name of the pet and returns the name of its owner.
- The save_as_json method takes as a parameter the name of the file and saves it in JSON format with that name. You can assume the extension (if any) will be part of the provided name. You can organize your JSON file however you want.
- The read_json method takes as a parameter the name of the file to read and loads that file. This will replace all of the pets currently in memory.
- The get_all_species method takes no parameters and returns a Python set of the species of all pets.
For example, your class could be used like this:
If you implement a Pet class (which is a natural option, but not required), then when you save it, you'll need to translate the information into one of the built-in object types the json module recognizes, and translate it back the other way when you read it.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
this code is missing the duplicate name error. How can this be added?
this code is missing the duplicate name error. How can this be added?
- No written by hand solutionarrow_forwardwrite a software that creates an object of that type. Insert data into that object, and then use of the algorithms available for that type to manipulate it. Write a short description of the data type you used, of the method you used to insert data into the object, and of the algorithm that you used. Finally, describe a different algorithm that you could have used to manipulate your object, and indicate a situation where that algorithm could be useful.arrow_forwardThe goal for Lab07 is to use the provided Student class and create an array of Student objects that is stored in a School object. This program uses a Student class that is provided(picture attached!). The class is placed in its own separate file and should not be altered. This project started with Lab06a and uses the same Student class. Part one of Lab07 is similar to the Lab06b. The difference is that Lab06b used static 1D arrays and Lab07 uses dynamic ArrayList arrays. The output is the same. In part two, adds the linearSearch and the binarySearch methods. Each search method is tested with an existing search record and one that does not exist. Tom 21 1.685 Ann 34 3.875 Bob 18 2.5 Jan 45 4.0 Joe 27 2.975 Sue 19 3.225 Jay 30 3.65 Meg 38 2.0 Art 40 3.999 Deb 35 2.125 7 -1 Ann 34 3.875 Art 40 3.999 Bob 18 2.5 Deb 35 2.125 Jan 45 4.0 Jay 30 3.65 Joe 27 2.975 Meg 38 2.0 Sue 19 3.225 Tom 21 1.685 7 -1arrow_forward
- Write in C++arrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forwardFor this project you will use the file included in the attached zip file. It is a series of fictional exam records. You must create a Python application that reads this file, assigns a letter grade to each student based on the scale below, outputs the student name, grade, and letter grade to the screen, and outputs that same information into a comma separated values file. You must use functions, parameters, returns, loops, collections and conditions, and some kind of design (pseudocode or flowcharts). Naming and organization counts. Functions to consider: opening a file, closing a file, reading records, writing records, determining letter grade, and writing to console. Grade scale to use in the application: A: >95% A-: >91 and <95 B+: >87 and <91 B: >83 and <87 B-: >80 and <83 C+: >78 and <80 C: >75 and <78 D: >70 and <75 F: <70arrow_forward
- python: def pokehelp(poke_name, stat_min): """ Question 4 - API You are looking for a Pokemon that can help you with your programming homework. Since Porygon is made of code, you decide to look into the species. Using the given API, return a dictionary that returns the name of each of Porygon's stats with a base stat GREATER THAN the given number, mapped to their value. Do not hardcode Porygon's stats into the results! It is not the only test case. Base URL: https://pokeapi.co/ Endpoint: api/v2/pokemon/{poke_name} Args: Pokemon name (str), stat minimum (int) Returns: Dictonary of stats >>> pokehelp("porygon", 65) {'defense': 70, 'special-attack': 85, 'special-defense': 75} >>> pokehelp("koraidon", 100) {'attack': 135, 'defense': 115, 'speed': 135} """ # pprint(pokehelp("porygon", 65)) # pprint(pokehelp("koraidon", 100))arrow_forwardPython Please. and the data file is: 2121211143534722arrow_forwardIN JAVA, DO THESE INTERFACES IN POINT AND LINE CLASSESarrow_forward
- how to write a method that reads in any csv file and extracts the data from the csv file into header and the remaining data using the csv module, and stores them in instance variables. also how to write a code to handle potential errors with file content such as empty file and file not found in python?arrow_forwardThe goal for Lab06b is to use the provided Student class (ATTACHED IN IMAGE) and create an array of Student objects that are stored in a School object. This program uses a Student class that is provided and shown below. The class is placed in its own separate file and should not be altered. This program sequence started with Lab06a. It is a reminder that it is the same Student file used by Lab06a. This lab will add data processing to the earlier Lab06a. This program will continue with the Lab06b program that performs some data processing on the Student records. For this lab 10 Student objects need to be constructed and placed in a students array, which is stored in a School object. You actually did this already for Lab06a. You also need to complete the School constructor, addData method and toString Method, which were in Lab06a. Feel free to just copy them over. You need to complete three bubbleSort methods; one that sorts according to the student gpa., one for age and one for name.…arrow_forwardSolve this question using java language. you have to read the information from a file then print them in a file please read the instructour carefully, also look at the attach images to help you to solve it. This tips will help you What You Must Implement:You must define a class named MediaRental that implements the MediaRentalInt interface functionality(index A). You must define classes that support the functionality specified by the interface. The followingspecifications are associated with the project:1. Define a class named MediaRental. Feel free to add any instance variables you understand are needed or anyprivate methods. Do not add any public methods (beyond the ones specified in the MediaRentalInt interface).2. The media rental system keeps track of customers and media (movies ,music albums and games). A customerhas a name, address as string , a plan and two lists. One list represent the media the customer is interested inreceiving and the second one represents the media…arrow_forward
- 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