Python Programming  I would like to change the program below to where the output is changed to look more like a table like this example below:  Part Num             Description         Quantity              Price                      Total 1001                       Hammer              20                    15                         300 1002                       locks                    15                    5                            75   Program: - #Defining the class Invoice class Invoice(object):     #Declaring the Variables      part_num = ' '     part_description = ' '     quantity = 0     price = 0     #Defining the __init__ method to initialize the variables     def __init__(self,part_num,part_description,quantity,price):         self.part_num = part_num         self.part_description = part_description         self.quantity = quantity         self.price  = price     #Defining the method that returns  the entered information     def display(self):         return 'Part number is: ' + self.part_num + '\nPart description is: ' + self.part_description + '\nQuantity of item is: ' + str(self.quantity) + '\nPrice per item is: ' + str(self.price)     #Defining the method that calculates and return the Invoice amount     def calculate_invoice(self):         return self.quantity*self.price     #Defining the class method that ask the user to enter the details      @classmethod     def get_user_input(self):         while 1:                part_num = input("\nPlease enter the part number: ")             part_description = input("Please enter the part description: ")             quantity = int(input("Please enter the quantity of item: "))             price = float(input("Please enter the price of item: "))             #Checking the validation             if(quantity < 0 or price <= 0):                 print("Invalid input! Please try again")                 continue             else:                    return self(part_num,part_description,quantity,price) #Creating the object of Class and calling the class method ob = Invoice.get_user_input() #Calling the method to display the entered data print(ob.display()) #Calling the method to display the Invoice amount print('\nInvoice amount is: {:.2f}'.format(ob.calculate_invoice()))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Python Programming 

I would like to change the program below to where the output is changed to look more like a table like this example below: 

Part Num             Description         Quantity              Price                      Total

1001                       Hammer              20                    15                         300

1002                       locks                    15                    5                            75

 

Program: -

#Defining the class Invoice

class Invoice(object):

    #Declaring the Variables 

    part_num = ' '

    part_description = ' '

    quantity = 0

    price = 0

    #Defining the __init__ method to initialize the variables

    def __init__(self,part_num,part_description,quantity,price):

        self.part_num = part_num

        self.part_description = part_description

        self.quantity = quantity

        self.price  = price

    #Defining the method that returns  the entered information

    def display(self):

        return 'Part number is: ' + self.part_num + '\nPart description is: ' + self.part_description + '\nQuantity of item is: ' + str(self.quantity) + '\nPrice per item is: ' + str(self.price)

    #Defining the method that calculates and return the Invoice amount

    def calculate_invoice(self):

        return self.quantity*self.price

    #Defining the class method that ask the user to enter the details 

    @classmethod

    def get_user_input(self):

        while 1:   

            part_num = input("\nPlease enter the part number: ")

            part_description = input("Please enter the part description: ")

            quantity = int(input("Please enter the quantity of item: "))

            price = float(input("Please enter the price of item: "))

            #Checking the validation

            if(quantity < 0 or price <= 0):

                print("Invalid input! Please try again")

                continue

            else:   

                return self(part_num,part_description,quantity,price)

#Creating the object of Class and calling the class method

ob = Invoice.get_user_input()

#Calling the method to display the entered data

print(ob.display())

#Calling the method to display the Invoice amount

print('\nInvoice amount is: {:.2f}'.format(ob.calculate_invoice()))

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education