Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago