Question

Python 3 Question: All I need is for someone to edit the program with comments that...

Python 3 Question:

All I need is for someone to edit the program with comments that explains what the program is doing (for the entire program)

def main():
    developerInfo() #i left this part out 
    retail = Retail_Item()
    test = Cash_Register()
    test.data(retail.get_item_number(), retail.get_description(),
              retail.get_unit_in_inventory(), retail.get_price())
    answer = 'n'

    while answer == 'n' or answer == 'N':
        test.Menu()
        print()
        print()
        Number = int(input("Enter the menu number of the item "
                           "you would like to purchase: "))
        if Number == 8:
            test.show_items()
        else:
            test.purchase_item(Number)
        answer = input("Are you ready to check out ?")
        x = 1
        while x == 1:
            if answer == 'y' or answer == 'n':
                x = 0
            else:
                print("Invalid input!")
                answer = input("Are you ready to check out ?")

    else:
        test.get_total()
        test.clear()


class Retail_Item:

    def __init__(self):
        self.__item_number = [1000, 2000, 3000, 4000, 5000, 6000, 7000]
        self.__description = ['Pants', 'Jeans', 'Shirt', 'Dress', 'Socks', 'Sweater', 'Jacket']
        self.__unit_in_inventory = [10, 2, 15, 3, 50, 5, 1]
        self.__price = [19.99, 25.95, 12.50, 79.00, 1.98, 49.99, 85.95]

    def get_item_number(self):
        return self.__item_number

    def get_description(self):
        return self.__description

    def get_unit_in_inventory(self):
        return self.__unit_in_inventory

    def get_price(self):
        return self.__price


class Cash_Register:

    def __init__(self):
        self.__item_number_list = []
        self.__description_list = []
        self.__unit_list = []
        self.__price = []
        self.__total_item_number = []
        self.__total_des = []
        self.__total_price = []
        self.__sub_total = 0

    def data(self, list1, list2, list3, list4):
        self.__item_number_list = list1
        self.__description_list = list2
        self.__unit_list = list3
        self.__price = list4

    def Menu(self):
        print("Items available for Purchase:")
        print("1. Pants")
        print("2. Jeans")
        print("3. Shirt")
        print("4. Dress")
        print("5. Socks")
        print("6. Sweater")
        print("7. Jacket")
        print("8. Show Inventory")

    def purchase_item(self, Number):
        self.__total_item_number.append(self.__item_number_list[Number - 1])
        self.__total_des.append(self.__description_list[Number - 1])
        self.__total_price.append(self.__price[Number - 1])
        if self.__unit_list[Number - 1] - 1 >= 0:
            self.__unit_list[Number - 1] = self.__unit_list[Number - 1] - 1
        else:
            print("The item is out of stock")

    def show_items(self):
        print('Item Number', '{:>18}'.format('Description'),
              '{:>24}'.format('Units in inventory'),
              '{:>11}'.format('Price'))
        for a in range(0, 7):
            print('   ', '{:<17}'.format(self.__item_number_list[a]),
                  '{:<20}'.format(self.__description_list[a]),
                  '{:<15}'.format(self.__unit_list[a]),
                  '{:>8}'.format(format(self.__price[a], '.2f')))

    def get_total(self):
        print('Item Number', '{:>18}'.format('Description'), '{:>19}'.format('Price'))
        for a in range(0, len(self.__total_item_number)):
            print('   ', '{:<17}'.format(self.__total_item_number[a]),
                  '{:<18}'.format(self.__total_des[a]),
                  '{:>9}'.format(format(self.__total_price[a], '.2f')))
        print()
        print()
        self.__sub_total = sum(self.__total_price)
        tax = self.__sub_total * 0.0825
        total_price = self.__sub_total * 1.0825
        print('{:<12}'.format('Sub Total:'),
              '{:>10}'.format(format(self.__sub_total, '.2f')))
        print('{:<12}'.format('Tax:'),
              '{:>10}'.format(format(tax, '.2f')))
        print('{:<12}'.format('Total Price:'),
              '{:>10}'.format(format(total_price, '.2f')))

    def clear(self):
        self.__total_item_number = []
        self.__total_des = []
        self.__total_price = []
        input('Press any key to continue')

main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

I have included the screenshot of the code with comments

def main(): developerInfo() #i left this part out retail = Retail_Item() # a Retail_Item object is created test = Cash_Regist

36 37 38 class Retail_Item: #Retail_Item item class 39 40 def _init__(self): #constructor 41 #initializing its data members a

self._total_des = [] self._total_price = [] #__sub_total is initialized with value o self. __sub_total = 0 def data(self, lis

def show_items(self): #method to show items #it will print Item Number, Description, Units in inventory, Price as heading pri

135 136 137 138 main() self. total_des = [] self. _total_price = [] input(Press any key to continue) #calling the main meth

If you find this answer useful , then please rate positive, thankyou

Add a comment
Know the answer?
Add Answer to:
Python 3 Question: All I need is for someone to edit the program with comments that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python Write a class named RetaiI_Item that holds data about an item in a retail...

    in python Write a class named RetaiI_Item that holds data about an item in a retail store. The class should store the following data in attributes: • Item Number • Item Description • Units in Inventory • Price Create another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should include the following methods: • A method named purchase_item that accepts a...

  • I am currently facing a problem with my python program which i have pasted below where...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • Hi, can someone offer input on how to address these 4 remain parts the zybook python...

    Hi, can someone offer input on how to address these 4 remain parts the zybook python questions?   4: Tests that get_num_items_in_cart() returns 6 (ShoppingCart) Your output ADD ITEM TO CART Enter the item name: Traceback (most recent call last): File "zyLabsUnitTestRunner.py", line 10, in <module> passed = test_passed(test_passed_output_file) File "/home/runner/local/submission/unit_test_student_code/zyLabsUnitTest.py", line 8, in test_passed cart.add_item(item1) File "/home/runner/local/submission/unit_test_student_code/main.py", line 30, in add_item item_name = str(input('Enter the item name:\n')) EOFError: EOF when reading a line 5: Test that get_cost_of_cart() returns 10 (ShoppingCart)...

  • I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • I try to define a PYTHON program that can print the largest factor of the number...

    I try to define a PYTHON program that can print the largest factor of the number except for the number itself. Ex: enter n as 15, the program will print: 5. The factor of 15 is 15, 5, 3, 1, but 15 will not be counted in this case. If enter a prime number, it will print 1. I am not sure what I did wrong here, please point out my mistake and advise how should I improve. def largest_factor(n)...

  • PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please...

    PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList:     def __init__(self):         self.__head = None         self.__tail = None         self.__size = 0     def insert(self, i, data):         if self.isEmpty():             self.__head = listNode(data)             self.__tail = self.__head         elif i <= 0:             self.__head = listNode(data, self.__head)         elif i >= self.__size:             self.__tail.setNext(listNode(data))             self.__tail = self.__tail.getNext()         else:             current = self.__getIthNode(i - 1)             current.setNext(listNode(data,...

  • Python Expert, I need your help: I need to write a function(rev_int_rec) that take an integet...

    Python Expert, I need your help: I need to write a function(rev_int_rec) that take an integet number(num = 1234567) and retrive the last digit using (lastDigit = num % 10) and add it to a queue. Remove each last digit from num using the % operator Add each last digit to the queue, with each round of recursion reduce num by dividing by 10. Base case is when num is less than 10 # Base case: If num < 10...

  • Python3 programming help needed LAB*: Program: Online shopping cart (continued) Need the below code edited to...

    Python3 programming help needed LAB*: Program: Online shopping cart (continued) Need the below code edited to run properly for the lab.. class ItemPurchase:     def __init__(self, nameitem='none', item_prc=0, item_quntity=0, item_descrp = 'none'):         self.nameitem = nameitem         self.item_prc = item_prc         self.item_quntity = item_quntity         self.item_descrp = item_descrp     def print_itemvaluecost(self):              string = '{} {} @ ${} = ${}'.format(self.nameitem, self.item_quntity, self.item_prc(self.item_quntity * self.item_prc))         valuecost = self.item_quntity * self.item_prc         return string, valuecost     def print_itemdescription(self):         string...

  • Python3 programming help needed LAB*: Program: Online shopping cart (continued) Need the below code edited to run prope...

    Python3 programming help needed LAB*: Program: Online shopping cart (continued) Need the below code edited to run properly for the lab.. class ItemPurchase:     def __init__(self, nameitem='none', item_prc=0, item_quntity=0, item_descrp = 'none'):         self.nameitem = nameitem         self.item_prc = item_prc         self.item_quntity = item_quntity         self.item_descrp = item_descrp     def print_itemvaluecost(self):              string = '{} {} @ ${} = ${}'.format(self.nameitem, self.item_quntity, self.item_prc(self.item_quntity * self.item_prc))         valuecost = self.item_quntity * self.item_prc         return string, valuecost     def print_itemdescription(self):         string = '{}: {}'.format(self.nameitem, self.item_descrp)         print(string , end='\n')         return string class Shopping_Cart:     #Parameter...

  • PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment...

    PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT