Question

In: Computer Science

PYTHON Part A. Write a program for salespersons to show discounted prices. a) Request the salesperson...

PYTHON

Part A. Write a program for salespersons to show discounted prices.

a) Request the salesperson to enter the listed price of a product
b) Write a function to meet the requirements:
i. The function takes the listed price as a parameter
ii. Print a table which lists discounted prices (10%, 20%, 30%, 40%, and 50% off) (see below)
iii. Note that the printing job needs to be done inside the function [3 pts]

Part B. Write another program to meet additional requirements:
c) Request the salesperson to enter 2 inputs: (1) the listed price & (2) increment of discount rates.
For example: the salesperson can enter 0.05 to indicate a 5% discount increment.
d) Write a function to meet the requirements:
i. The function takes two parameters: (1) the listed price & (2) the rate increment
ii. Using a loop, print a table which lists discounted prices, up to 50% off (see below)
iii. Note that the printing job needs to be done inside the function

Note: All prices (including listed & discounted) must be presented with 2 decimals and $. For discount rate increment, the smallest possible input is 0.01, i.e., 1%. No need to worry if a rate incremental has 3 decimals or more.

Solutions

Expert Solution

PART-A

#function to print the discount rates
def printDiscounts(Listed_Price):
print("Listed Price : $",Listed_Price);#print the listed Price
#print the price after 10% discount
print("After 10% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*0.1)))
#print the price after 20% discount
print("After 20% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*0.2)))
#print the price after 30% discount
print("After 30% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*0.3)))
#print the price after 40% discount
print("After 40% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*0.4)))
#print the price after 50% discount
print("After 50% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*0.5)))
#read the listed price from user   
Listed_Price = (float)(input("Enter the Listed Price of Product : "))
#call to printDiscounts()
printDiscounts(Listed_Price)

output

PART-B

#function to print the discount rates
def printDiscounts(Listed_Price,IncDiscount):
print("Listed Price : $",Listed_Price);#print the listed Price
#loop to print the incremented discounted amount
for i in range(1,6):
j= (i*10)/100 +IncDiscount;
#print the price after 10% discount
print("After ",(int)(j*100),"% discount Price : $","{0:.2f}".format(Listed_Price - (Listed_Price*j)))
#read the listed price from user   
Listed_Price = (float)(input("Enter the Listed Price of Product : "))
#READ THE incremented discount
IncDiscount = (float)(input("Enter the incremented discount : "))
#call to printDiscounts()
printDiscounts(Listed_Price,IncDiscount)

output


Related Solutions

FOR PYTHON: Write a python program for a car salesperson who works a five day week....
FOR PYTHON: Write a python program for a car salesperson who works a five day week. The program should prompt for how many cars were sold on each day and then prompt for the selling price of each car (if any) on that day. After the data for all five days have been entered, the program should report the total number of cars sold and the total sales for the period. See example output. NOTE: duplicate the currency format shown...
3. [1 pts] Part A. Write a program for the GW Admissions Office. a) Request the...
3. [1 pts] Part A. Write a program for the GW Admissions Office. a) Request the staff to enter a string, to indicate someone’s NetID. b) Generates an email address, by appending “@gwmail.gwu.edu” to the user input c) Print the generated email account [2 pts] Part B. Write a program to meet additional requirements. In addition to requirements in Part A, your function should perform the following check: a) If the user input is longer than 10 characters (11 or...
MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
Use Python to solve, show all code Write a program that sums a sequence of integers...
Use Python to solve, show all code Write a program that sums a sequence of integers from a starting integer to and ending integer. The sequence is generated by skipping a value (e.g. 1,3,5,… or 2,6,10,14…). Prompt the user for a) a starting value greater than 0. Validate the value is greater than 0. b) the ending value. c) the value to skip Print out the sum of the numbers for the sequence. If the starting value is 2, the...
Answer question in Python, show all code: Write a program that calculates and displays the end...
Answer question in Python, show all code: Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed...
Write a Python program that performs the following list operations. Part A Define a list called...
Write a Python program that performs the following list operations. Part A Define a list called numList with elements. 84, 94, 27, 74, 19, 90, 16, 21, 56, 50, 77, 59, 41, 63, 18, 26, 80, 74, 57, 30, 40, 93, 70, 28, 14, 11, 43,65, 91, 83, 22, 53, 74, 44, 73, 55, 47, 74, 81 Display the followings: All the numbers in numList The number of elements in numList The smallest number in numList The largest number in...
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT