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...
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,...
Python It's time to put everything together!  This week you will write a program that mimics an...
Python It's time to put everything together!  This week you will write a program 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. I leave the bulk of design up to you (hint - think A LOT about it before you start programming!!) but it should include all of the following: The basics - Add items to a cart until the user...
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....
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