Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

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.

Python, Programming

  • Category:- Python
  • Reference No.:- M93094824

Have any Question?


Related Questions in Python

Question why is software configuration management

Question : Why is software configuration management considered an umbrella activity in software engineering? Please include examples and supporting discussion. The response must be typed, single spaced, must be in times ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Environment setupthe first mini project will be based on

Environment Setup The first mini project will be based on Ladder Logic programming. We will be using Schneider Electric's IDE called SoMachine Basic to do the programming. The latest ver- sion of SoMachine Basic for Wind ...

Question write a simple python program that takes use

Question: Write a simple python program that takes use inputs as non-zero digits and converts them into binary form. The response must be typed, single spaced, must be in times new roman font (size 12) and must follow th ...

Questionwhat is a python development frameworkgive 3

Question What is a python development framework? Give 3 examples python development framework used today. and explain which development framework is used in which industry.

Question a software company sells a package that retails

Question : A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program usi ...

Show times in tmus and seconds1 an associate grasps an oven

Show times in TMUs and seconds. 1. An associate grasps an oven door within reach and pulls it open 18 inches with the left hand (he does not relinquish control of the door). With a pan in the right hand, he carefully pos ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Learning outcomes lo3 - research develop and document a

Learning Outcomes LO3 - Research, develop, and document a basic security policy, and analyse, record, and resolve all security incidents LO4 - Identify and assess the threats to, and vulnerabilities of networks Assessmen ...

Foundations of programming assignment - feduni bankingthis

Foundations of Programming Assignment - FedUni Banking This assignment will test your skills in designing and programming applications to specification. Assignment Overview - You are tasked with creating an application t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As