Question: This is the TEST HARNESS and i need to create SHOPPER CLASS and i need this out put. Test harness: print( f 'Price dict: {Shopper.price_list()}')

This is the TEST HARNESS and i need to create SHOPPER CLASS and i need this out put.

Test harness:

print(f'Price dict: {Shopper.price_list()}')

print(f'Sales list: {Shopper.sale_items()}')

nar = Shopper('Narendra', 20) #create a shopper object

print(f' {nar}') #display the object

items = 'bread milk'.split() #list of items to buy

print(f' {nar.name} is purchasing: {items}')

nar.purchase(items) #buy the items

print(f'{nar}') #display the object

items = 'apple pepper cauliflower'.split()

print(f' {nar.name} is purchasing: {items}')

nar.purchase(items)

print(f'{nar}') #display the object

#you don't need to understand the code below

#it is for verification purposes

members = [member for member in dir(Shopper) if not member.startswith('_')]

print(f' Public members of the class: {members}')

properties = [member for member in members if not callable(getattr(Shopper, member))]

print(f'Public properties: {properties}')

methods = [member for member in members if callable(getattr(Shopper, member))]

print(f'Public methods: {methods}')

Program Output

Your output must be identical to the below.

Price dict: {'apple': 1.99, 'bread': 2.19, 'milk': 4.96, 'pepper': 1.25}

Sales list: ['pepper banana']

Narendra cash in hand $20.00

items:

[]

Narendra is purchasing: ['bread', 'milk']

Narendra cash in hand $13.56

items:

[('bread', 2.19), ('milk', 4.96)]

Narendra is purchasing: ['apple', 'pepper', 'cauliflower']

Narendra cash in hand $8.01

items:

[('bread', 2.19), ('milk', 4.96), ('apple', 1.99), ('pepper', 1.0625), ('cauliflower', 2.5)]

Public members of the class: ['name', 'price_list', 'purchase', 'sale_items']

Public properties: ['name']

Public methods: ['price_list', 'purchase', 'sale_items']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!