Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with my program. It is running perfectly, but the zybooks grader is not recognizing my classes. My code is in python 3.
I need help with my program. It is running perfectly, but the zybooks grader is not recognizing my classes. My code is in python 3. The class, "Item", is in my program, but it is giving me an EOFError.
This is the whole code. the output is on the bottom.
The IDE im using is in Zybooks.
1 class Item(object): def __init__(self): self.item_name - "empty" self.item_price- self.item_quantity - def print_item_cost(self): print("%s Xd @$%.2f - $%.2f" % (self.item_name, self.item_quantity, self.item_price, self.item_price" self.item_quantity)) 10 def get_total_cost(self): return int(self.item_price" self.item_quantity) 14 13 class Checkout(): def __init__(self): self.customer_name - "none" 16 self.current date - "May 13, 2019" self.cart_items - 0 15 17 def print_name_date(self): print() def add_item(self, ItemToPurchase): self.cart_items.append(ItemToPurchase) def remove iten(self, Iten_name): found - False for item in self.cart_items: 16 item. item name item name: self.cart_items.remove(item) found - True print(self.cart_items) break if not found: print("Item not found in cart. Nothing renoved") 33 35 36 37 der modify item(self, nane, gty) found - False for item in self.cart Items: 38 0 and ItemToPurchase.name -- "none" and Itent def modify_iten(self, name, qty): found - False for item in self.cart_items: if item.item_name == name: ItemToPurchase - item if ItemToPurchase. item_price and ItemToPurchase. item_quantity - pass else: item.item_quantity - qty found True break if not found: print("Item not found in cart. Nothing modified.") def get_num_items_in_cart(self): return len(self.cart_items) def get_cost_of_cart(self): total - 0.00 for item in self.cart_items: total - item.get_total_cost() return total def print_total(self): self.print_name_date() for item in self.cart_items: item.print_iten_cost if self.get_num_items_in_cart() > 0: print(" Total: $%.2f" % self.get_cost_of_cart() else: print("SHOPPING CART IS EMPTY") SEO 68 cart - Checkout() 69 70 name - input("Enter customer's name: ") 71 date - input("Enter today's date: ") 72 print) print() cart.customer_name = name 5 cart.current date - date 6 print("CART: Customer's name: %s Today's date: %s" % (cart.customer_name, cart.current_date)) 7 print() 78 print("Total: $0.00") 79 print) 83 81 def print_menu(): print("MENU") print("a. Add item to cart nr . Remove item from cart c . Change iten quantity g - Quit") 85 def output_shopping_cart(): cart.print_total() 86 96 88 def add item(): print("ADD ITEM TO CART") 90 name - input("Enter the item name: ") price - float(input("Enter the item price: ")) quantity - float(input("Enter the item quantity: ")) new item - Item() new item. Item name - nane new_item. item_price - price new_item. item_quantity - quantity cart.add_item(new_item) 98 99 100 def renove item(): 101 print("REMOVE ITEM FROM CART") 102 name - input("Enter none of iten to remove: ") 103 cart.remove_item(name) 104 105 106 def change_qty(): 107 print("CHANGE ITEM QUANTITY") iten name input("Enter the item name: ") 109 iten_qty - input("Enter the new quantity: ") 110 rart mit itamfiram na nitantull 108 item_name - input("Enter the item nane: ") item_qty - input("Enter the new quantity: ") cart.modify_iten(iten_name, int(item_qty)) 121 123 124 126 2 cart.print_total 13 print_menu() 14 choice - input("Choose an option:") 15 while choice - '': if choice -- 'a': add_item() print("CART: Customer's name: %s Today's date: %s % (cart.customer_name, cart.current_date)) 119 cart.print_total() print_menu() choice - input("Choose an option: ") 122 elif choice - 'r': renove_item() print("CART: Customer's name: %s Today's date: %s % (cart.customer_name, cart.current_date)) 125 cart.print_total() print_menu) 127 choice - input("Choose an option: ") 128 elif choice -- 'c': 129 change_qty() 130 print("CART: Customer's name: %s Today's date: %s" % (cart.customer_name, cart.current_date)) cart.print_total) 132 print_menu() 133 choice - input("Choose an option: ") 134 elif choice - 'a': 135 break else: 137 choice - input("Choose an option:") 138 while choice t'a': choice a 140 add_iten() 141 print("CART: Customer's name: Xs Today's date: %s" (cart.customer name, cart.current_date)) 142 cart.print_total() 143 print_men() choice - input("Choose an option: ") 145 elif choice 145 remove item() 131 136 139 MENU 159 160 161 162 163 164 165 166 167 168 169 170 171 172 elif choice -- 'r': remove_iten() print("CART: Customer's name: %s Today's date: %s % (cart.customer_name, cart.current_date)) cart.print_total() print menu() choice - input("Choose an option: ") elif choice 'c': change_qty) print("CART: Customer's name: %s Today's date: %s" % (cart.customer_name, cart.current_date)) cart.print_total() print_menu() choice - input("Choose an option: ") elif choice - '': break else: choice - input("Choose an option:") while choice !- 'q': if choice "a": add_item() print("CART: Customer's name: %s Today's date: %s" % (cart.customernane, cart.current_date)) cart.print_total) print_menu() choice - input("Choose an option: ") elif choice remove_iten) print("CART: Customer's name: %s Today's date: %s" % (cart.customer_name, cart.current_date)) cart.print_total() print_menu() choice - input("Choose an option: ") elit choice 'c': change_qty) print("CARTI Customer's name: %s Today's date: %s" % (cart.customer_name, cart.current_date)) cart.print_total() print_menu() choice - input("Choose an option: ") elif choice "q". break 173 174 175 176 177 178 179 130 1: Test Item Class A 0/2 Your output Enter customer's name: Traceback (most recent call last): File "zyLabsUnitTestRunner.py", line 4, in Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started