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 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...
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...
Day of week Write a program that asks the user for a date (year, then month,...
Day of week Write a program that asks the user for a date (year, then month, then day, each entered as a number on a separate line), then calculates the day of the week that date falls on (according to the Gregorian calendar) and displays the day name. You may not use any date functions built into Python or its standard library, or any other functions that do this work for you. Hint: Reverend Zeller may be useful, but his...
Bob works for Jet Skis Incorporated, and is the top salesperson for the past five years....
Bob works for Jet Skis Incorporated, and is the top salesperson for the past five years. The manager Bill tells Bob “I have to let you go, good luck finding a new job.” Bob asks why and Bill says “You are an at-will employee, I do not have to give you a reason.” Bob, who is 44 years old, notices three other employees were also terminated, all identified as Hispanic ethnicity, over 40 years of age. Does Bob have any...
Bob works for Jet Skis Incorporated, and is the top salesperson for the past five years....
Bob works for Jet Skis Incorporated, and is the top salesperson for the past five years. The manager Bill tells Bob “I have to let you go, good luck finding a new job.” Bob asks why and Bill says “You are an at-will employee, I do not have to give you a reason.” Bob, who is 44 years old, notices three other employees were also terminated, all identified as Hispanic ethnicity, over 40 years of age. Does Bob have any...
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 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,...
Design and implement the class Day that implements the day of the week in a program....
Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day: Set the day. Print the day. Return the day. Return the next day. Return the previous day. Calculate and return the day by adding certain days to the current day. For example, if the current day...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT