Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python program that does the following: A pet shop wants to give a discount to its clients if they buy one or more

Write a python program that does the following: image text in transcribed

A pet shop wants to give a discount to its clients if they buy one or more pets and at least five other items. The discount is equal to 20 percent of the cost of the other items, but not the pets. Implement a function def discount(prices, is Pet, nltems) The function receives information about a particular sale. For the ith item, pricesi] is the price before any discount, and isPet[i] is true if the item is a pet. Write a program that prompts a cashier to enter each price and then a Y for a pet or N for another item. Use a price of-1 as a sentinel. Save the inputs in a list. Call the function that you implemented, and display the discount. (Notes: you should have two lists; one for saving price information and another one saving for saving whether "True" for buying a pet or "False" for not buying a pet; If the customer buys 6 pets, he/she still will receive no discount because the discount option is not applicable for the pet; also your program should recognize both uppercase and lowercase letter) A simple example: assuming a customer buys 5 items. 4 of them are non-pet items and 1 of them is a pet. The total price of non-pet items is $20. This customer receive S4 as the discount (20*0.8) Example output 1 (6 items; all of them are pets): Enter the price (-1 to quit): 2e Is it a pet (Y/ N)? Y Enter the price (-1 to quit): 20 Is it a pet (Y / N)? Y Enter the price (-1 to quit) 2e Is it a pet (Y/N? Y Enter the price (-1 to quit): 2e Is it a pet (Y/ N)? Y Enter the price (-1 to quit): 20 Is it a pet (Y / N)? Y Enter the price (-1 to quit) 2e Is it a pet (Y/ N)? Y Enter the price (-1 to quit): -1 The discount is $0.00

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

Students also viewed these Databases questions