Question
PLEASE READ! Trying to correct a previous response. Please help edit the provided python script below. Write a program that takes quarterly sales for an
PLEASE READ! Trying to correct a previous response. Please help edit the provided python script below.
Write a program that takes quarterly sales for an organization ( in thousands of dollars) over a year and calculates the total sales. The output should change according to the sales entered. Add try/except block as well as an indication of whether total sales are low (under $50,000), medium ($50K or higher and under $150K), or high ($150K or higher). Also, issue a warning message in the event that sales are under $20K. If the sales entered are non-numeric, use a try/except /else block to indicate that the application only takes numeric data as inputs.
Input:
a) python C:\Users eda\DataProgramming\M3\assign3-7.py 1000 2500 1750 10250
b) python C:\Users eda\DataProgramming\M3\assign3-7.py 1000 cat 1750 10250
c) python C:\Users eda\DataProgramming\M3\assign3-7.py 10000 17500 14750 10250
Output:
a) Quarterly sales: $1000, $2500, $1750, $10250 Total sales: $15500 Sales: low Warning: Need to improve sales
b) All sales should be numeric.
c) Quarterly sales: $10000, $17500, $14750, $10250 Total sales: $52500 Sales: med
Script provided:
import sys
total_sales = 0
for i in range(1, len(sys.argv)): try: sales = int(sys.argv[i]) total_sales += sales print("Quarterly sales: $" + str(sales)) except ValueError: print("All sales should be numeric.") break else: print("Total sales: $" + str(total_sales)) if total_sales = 50000 and total_sales = 150000: print("Sales: high")
Output should appear as:
Quarterly sales: $1000, $2500, $1750, $10250
Total sales: $15500
Sales: low
Warning: Need to improve sales
Quarterly sales: $1000 Total sales: $1000 Warning: Need to improve sales Quarterly sales: $2500 Total sales: $3500 Warning: Need to improve sales Quarterly sales: $1750 Total sales: $5250 Warning: Need to improve sales Quarterly sales: $10250 Total sales: $15500 Warning: Need to improve salesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started