Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python -create a Merchandise instance for 10 hammers costing $14.95 each.

ID: 668435 • Letter: U

Question

Using Python

-create a Merchandise instance for 10 hammers costing $14.95 each.

-create another Merchandise object for 6 necklaces costing $799.99 each.

-run the __str__ methods of both objects.

-prompt the user for a new quantity for the hammer object, then change this attribute with the setter method.

-prompt the user for a new cost for the necklace object, then change this attribute with the setter method.

-verify the changes by running the __str__ methods again.

-display the inventory value for each object as well.

Will look something like this

hammer, 10 @ $14.95
necklace, 6 @ $799.99
Enter new quantity for hardware 12
Enter new cost for jewelry 659
hammer, 12 @ $14.95
Inventory value: $179.40
necklace, 6 @ $659.00
Inventory value: $3,954.00

Explanation / Answer

working python code

# your code goes here
class xyz:
def __init__(self,name, a, b):
self.a = a
self.b = b
self.name = name

def __str__(self):
return '%s, (%d @$ %d)' % (self.name,self.a, self.b)

v1=xyz("hammer",10,14.95)
print v1
v2=xyz("necklace",6,799.99)
print v2
v3=raw_input("enter new cost for the hardware")
v4=raw_input("enter new cost for the jewelry")
v1.a=v3
v1.b=v4
v2.a=v3
v2.b=v4
print v1
print v2

  
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote