Write a python program that allows the user to enter

Assignment Help Python Programming
Reference no: EM132107355

This program use Python

Objective:

Practice working with a list of numbers.

Practice writingfunction definitionsthat useparametersandreturna value.

Practice using astring accumulator.

Instructions:

Your employer needs a program that analyzes the monthly sales figures for each division.

Write a Python program that allows the user to enter a series of numbers and places the numbers (not string values) in a list. Each number entered by the user is the monthly sales amount for one division.

Use a sentinel-controlled loop to get input from the user and place each value entered into the list as long as the value is not negative. As soon as any negative value is entered, stop the loop (without putting that illegal value into the list).

One objective of this assignment is to apply algorithms we have studied to solve problems. You will do this by writing a function definitionto implement each algorithm.

Every function must get information only from its parameters, not from "global" variables. Several of these tasks can also be accomplished with built-in functions. In those cases, your code should demonstrate both approaches and show that the results are the same.

Add code to your program to do the following:

Write a function definition that uses a loopand astring accumulatorto produce andreturn astringresultthat includes the user-entered sales figures formatted to look similar to this when it is printed:

{$12.95, $1,234.56, $100.00, $20.50}

Notice the dollar signs, commas, digits after the decimal point, and curly braces. Plan this one on paper before you start writing code. Add code that calls this function and prints the result.

Show thehighestnumber in the list -- the sales leader! Do this in two ways. First, use the built-in 'max' function. Then, write your own 'max2' function definition that accomplishes the same thing by using a loop to find the highest value.

Show thelowestnumber in the list -- the sales loser. Do this in two ways. First, use the built-in 'min' function. Then, write your own 'min2' function definition that accomplishes the same thing by using a loop to find the lowest value.

Show the total sales for the company for the month -- thesumof all the numbers in the list. Once again, write a function definition that uses a loop and an accumulator to compute this sum.

Show theaverageof all the numbers in the list. (Be sure to carefully check the result!)

Ask the user to enter athreshold(a number). Write a function that takes a list and the threshold as parameters, and returns a new list that contains all values in the original list that aregreaterthan or equal to the threshold-- these divisions get awards for high sales! The new list may, of course, be empty.

Program Organization:

The program should be organized as a series of function definitions. The 'main' function should contain the user interface as well as code that "calls" the other functions and then shows the results to the user. Only the 'main' function should interact with the user. No other function should print anything; rather, each function "returns" a value. Do not use any global variables.

Testing:

As always, be sure to test each result using representative data to make sure it is correct, and include comments showing documented test cases in your program.

Reference no: EM132107355

Questions Cloud

What is the combined exam 1 standard deviation : Professor Matt took a sample of 208 students from her morning class and a sample of 119 students from her evening class. On Exam 1, all those sampled
New cases of mesothelioma : A new study found that there were 12 new cases of mesothelioma per 100,000 person-years of employment in the shipbuilding industry.
What quiz score is three standard deviations : The math quiz scores show that µ=75 and s=10. What quiz score is three standard deviations below the mean?
Compute the total and annual returns : Compute the total and annual returns on the described investment.
Write a python program that allows the user to enter : Write a Python program that allows the user to enter a series of numbers and places the numbers (not string values) in a list.
What is the average hourly pay rate : If this college has 6 part-time teachers who only meet minimum requirements, 18 with master's degrees, and 4 with doctorates, what is the average hourly pay
Define a class called odometer that will be used to track : Define a class called odometer that will be used to track fuel and mileage for automobile.
Write a program to read vehicles speed : Write a program to read vehicles speed, travel time and the vehicles MPG, calculate distance traveled and the number of gallons used.
Find the probability that the second roll : Let A denote the event that a 1 is obtained on the first roll, and let B denote the event that an even is obtained on the second roll. Find P(A and B).

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd