Practice working with a list of numbers

Assignment Help Basic Computer Science
Reference no: EM131427482

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Show theaverageof all the numbers in the list. (Be sure to carefully check the result!)
  6. 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: EM131427482

Questions Cloud

Review your peers movement assessment : Some joints have an incredible amount of movement in a near frictionless environment. Some joints are completely locked in place against bone, never to be moved again. All of these joints however have a huge influence on our quality of life and th..
File-naming conventions for four different operating : Research file-naming conventions for four different operating systems (not including UNIX, MS-DOS, Windows or Linux). Note the acceptable range of characters, maximum length, case sensitivity, etc.
Write a marketing report on gucci company brand : Write a marketing report on Gucci Company Brand. Analyze and evaluate the target market of Gucci, and then indicate how they serve their customers' needs and requirements
Discuss a compensation strategy that would support : The VP of Human Resource Management has asked you to present a PowerPoint presentation to upper management to discuss your previous findings. Those findings included culture in a global environment, expatriate turnover reduction, recruitment fact..
Practice working with a list of numbers : 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.
Explain the resources and capabilities that are required : Specify the unique value the company will offer in the selected markets. Discuss the resources and capabilities that are required. Analyze how the company will capture value and sustain competitive advantage over time.
Develop an employee compensation and benefits package : Imagine that you have just been hired by a new company as the director of the HR department. You have been tasked to hire a new secretary for the department and to develop an employee compensation and benefits package that will be used for that po..
Comment - whether you agree or disagree with given statement : Do you disagree? For each of the following statements, comment on whether you agree or disagree. If you disagree, explain why.
Excellent job researching : "Well, your team is doing an excellent job researching, and you've been keeping me up-to-date on your findings. My concern is that we are approaching this from a narrow-minded approach."

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Compute the loop transfer function

Compute the loop transfer function, LTF, the closed-loop transfer function, CLTF, and the return difference, RD, for the following block diagrams.

  Relationship for women who competed in multiple races

relationship for women who competed in multiple races.

  What is it security auditing and what does it involve

What is IT Security Auditing. What does it involve. Why are Governance and Compliance Important

  Which alternative would now be the most profitable

Using the Aspiration level criterion, if the profit level is set to be at least $300,000 and the loss level is set to be no more than $150,000 which alternative(s) must be eliminated?

  Structured query language

Refer to the database design crested in Lab 2: Modifying a Database Design in Visio to complete this Lab.  Perform the following steps in MySQL:

  Determine the worst case time complexity for each method

Modify the binary search algorithm to find the position of the first occurrence of a value that can occur multiple times in the ordered list. Verify your algorithm is still O(log n).

  Create a four-function fraction calculator

Create a four-function fraction calculator. Here are the formulas for the four arithmetic operations applied to fractions.

  Find the cpi spz etc and eac for the project

find the CPI, SPI, ETC, and EAC for the project.

  Represent 99 and -99 in 2s complement format

what are the largest(positive) and smallest (negative) integers a word can represent - Represent 99 and -99 in 2's complement format.

  Social media and electronic messages

Based on what you've read in the text about how business messages can use Social Media and electronic messages, consider what would be important when trying to reach Digital Natives? List the important elements that should be considered.

  Client of yours is concerned about external intrusion

Client of yours is concerned about external intrusion on their corporate network, and those inside their environment that they seek to fire! They've heard about firewalls and they need your professional opinion as to whether, with the implementation ..

  How many pins are needed for the integrated-circuit package

A ROM chip of 4096 x 8 bits has two enable inputs and operates from a 5-volt power supply. How many pins are needed for the integrated-circuit package? Draw a block diagram and label all input and output terminals in the ROM.

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