Question

In: Computer Science

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 for the total sales,

Example Output How many cars were sold on day 1? 1

Selling price of car 1? 30000

How many cars were sold on day 2? 2

Selling price of car 1? 35000

Selling price of car 2? 45000

How many cars were sold on day 3? 0

How many cars were sold on day 4? 1

Selling price of car 1? 30000

How many cars were sold on day 5? 0

You sold 4 cars for total sales of $140,000.00

Solutions

Expert Solution

totalCars = 0
totalSales = 0
for i in range(5):
n = int(input("How many cars were sold on day "+str(i+1)+"? "))
totalCars = totalCars + n
for j in range(n):
price = int(input("Selling price of car "+str(j+1)+"? "))
totalSales = totalSales + price
  
print("You sold "+str(totalCars)+" cars for total sales of $"+str('{:20,.2f}'.format( float(totalSales) )))

Output:

sh-4.3$ python3 main.py                                                                                                                                                                                                                                                  

How many cars were sold on day 1? 1                                                                                                                                                                                                                                      

Selling price of car 1? 30000                                                                                                                                                                                                                                            

How many cars were sold on day 2? 2                                                                                                                                                                                                                                      

Selling price of car 1? 35000                                                                                                                                                                                                                                            

Selling price of car 2? 45000                                                                                                                                                                                                                                            

How many cars were sold on day 3? 0                                                                                                                                                                                                                                      

How many cars were sold on day 4? 1                                                                                                                                                                                                                                      

Selling price of car 1? 30000                                                                                                                                                                                                                                            

How many cars were sold on day 5? 0                                                                                                                                                                                                                                      

You sold 4 cars for total sales of $          140,000.00


Related Solutions

PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar...
PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar date after January 1, 1900, which was a Monday. This program will need to account for leap years, which occur in every year that is divisible by 4, except for years that are divisible by 100 but are not divisible by 400. For example, 1900 was not a leap year, but 2000 was a leap year.
Write a Python program that uses function(s) for the following problem: A nutritionist who works for...
Write a Python program that uses function(s) for the following problem: A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consumed in a day (two inputs, one for number of fat grams and the other for number of carb grams). Then, she calculates the number of calories that result from the fat, using the following formula:...
Python This week you will write a program in Python that mimics an online shopping cart...
Python This week you will write a program in Python that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
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,...
Python This week you will write a program in Pyhton that mimics an online shopping cart...
Python This week you will write a program in Pyhton that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
Write a program that uses Python List of strings to hold the five student names, a...
Write a program that uses Python List of strings to hold the five student names, a Python List of five characters to hold the five students’ letter grades, and a Python List of four floats to hold each student’s set of test scores. The program should allow the user to enter each student’s name and his or her four test scores. It should then calculate and display each student’s average test score and a letter grade based on the average....
Who knows to do this topic with python code? Write a program to perform the following...
Who knows to do this topic with python code? Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and...
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.
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