DO NOT CLICK PAST THIS QUESTION UNTIL AFTER YOU HAVE TAKEN Y…
DO NOT CLICK PAST THIS QUESTION UNTIL AFTER YOU HAVE TAKEN YOUR EXAM. Remember to return to Canvas after you’ve completed your assessment to submit this quiz and end proctoring session.For any technical assistance, please contact Honorlock support thru the livechat at the bottom right of this page or by calling (855) 828-4004. Please navigate to Examplify at this time. DO NOT WRITE THIS PASSWORD DOWN You exam password is: dN9v39wG9nZV
Read DetailsA class definition called Library is given below. Create co…
A class definition called Library is given below. Create code that will allow programs that use this class to determine how many books are in a Library object by using the built-in ‘len’ feature. For example, coding “len(lib1)” for Library object “lib1” will return how many books are in it. class Library ( ): def __init__(self, name, owner, address): self.__name = name self.__owner = owner self.__address = addres self.__volumes = [ ] # Library container for books it has def addBook (self, b_obj): if type(b_obj) != Book: return False, ‘can only add Book objects’ self.__volumes.append(b_obj) return True, ‘added’
Read DetailsCreate a class called Cart that is used to hold items while…
Create a class called Cart that is used to hold items while doing on-line shopping. Cart is a subclass of the built-in list class. Write the class definition code (i.e. the signature line and constructor method) needed to allow other code to create a Cart object that has two attributes: the shopper’s name (cust_name) and a cart number (cartNo). cust_name is a string parameter while cartNo is an integer. cartNo is created by the class code and is 1 for the first cart created, 2 for the second, etc. Include a method called addItem() to add items to the cart. addItem() has two positional parameters: (1) item – the name of some item (type string), and (2) quantity to be added (type integer). For example item = ‘eggs’ and quantity = 2 adds two boxes of eggs to the cart. addItem() ensures the item to be added is one of the 6 items in the inventory dictionary below and that the quantity is an integer. However, it is possible that items will be added to the inventory at any time. It returns False with a reason if not. Otherwise, it adds the item to the cart list (‘self’), the quantity, and the extended price (quantity times the price taken from the inventory dictionary). What is added is a list with 3 elements: [, , ]. If the item () is already in the cart the method just adds the quantity to what’s already in the cart and updates the extended price. The method uses the parent class’s append method to add to the cart and returns True and a message that items were added. Example: if two boxes of eggs are added to a new Cart, that would appear this way in the cart: [ [‘eggs’, 2, 10.98] ]. If another box of eggs is added (parameters item = ‘eggs’ and quantity = 1) the item in the cart would be updated to [ [‘eggs’, 3, ‘16.97] ]. If two loaves of bread were added that cost 3.99 each, the cart (self) would be updated to [ [‘eggs’, 3, 16.97] , [‘bread’, 2, 7.98] ]. The following inventory has all the items that might be added to the cart (it’s a small inventory). Assume it’s part of your code as a class level attribute and do not retype it in your answer. inventory = {‘eggs’: 5.49, ‘milk’: 3.99, ‘fish’: 9.95, ‘beer’: 9.95, ‘rice’: 7.00, ‘bread’: 4.99}
Read Details