Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 4PE
Program Plan Intro
Program plan:
- • Declare a function named “NumberAnalysis()”.
- ○ Declare an empty list “ournumbers” to hold the input numbers.
- ○ Use a “for” loop to iterate up to the range of “20” and get “20” input numbers from the user and insert the numbers to the empty list “ournumbers” using “append()”.
- ○ Using the built-in functions “min()” to find the lowest number in the list “ournumbers” and display it using “print()” function.
- ○ Using the built-in functions “max()” to find the highest number in the list “ournumbers” and display it using “print()” function.
- ○ Using the built-in functions “sum()” to find the total of the numbers in the list “ournumbers” and display it using “print()” function.
- ○ To find the average of numbers in the list, the built-in function “sum()” is used to find the total of the numbers in the list “ournumbers” and sum of the numbers value is divided by the “len(ournumbers)”; result is displayed using “print()” function.
- • In the “main()” function:
- ○ Call the function “NumberAnalysis()”.
- • Finally, call the “main()” to execute the program.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
c++ circular linked list program where you need to create a playlist of songs and you need to loop the songs in the playlist and display what song the user want to play, what song user want to delete, user want to see what song is next in the playlist, and songs you want to delete in the playlist
PYTHON PROGRAMMING ASSIGNMENT
PYTHON PROGRAMMING LANGUAGE ASSIGNMENT
Create a new text document called names.txt (this is done by hand - not using programming) with the following names: Adam, Bryan, Charlie. Each name should be followed by a hard return (do not store them in a list).
Main Function. Write a program where the user enters a name. Using the read function, check to see if the name is in the text document. If it is, respond back to the user the name is found within the list.
Read Function. The read function should return the contents of the text document as a list.
Write Function. The write function should take the list and override the file with the new names list in reverse alphabetical order with a hard return after each name.
c++ double linked list program where you need to create a playlist of songs and you need to loop the songs in the playlist and display what song the user want to play, what song user want to delete, user want to see what song is next in the playlist
Chapter 7 Solutions
Starting Out with Python (4th Edition)
Ch. 7.2 - What will the following code display? numbers =...Ch. 7.2 - Prob. 2CPCh. 7.2 - Prob. 3CPCh. 7.2 - Prob. 4CPCh. 7.2 - Prob. 5CPCh. 7.2 - Prob. 6CPCh. 7.2 - Prob. 7CPCh. 7.2 - Prob. 8CPCh. 7.3 - Prob. 9CPCh. 7.3 - Prob. 10CP
Ch. 7.3 - Prob. 11CPCh. 7.3 - Prob. 12CPCh. 7.3 - Prob. 13CPCh. 7.4 - What will the following code display? names =...Ch. 7.5 - Prob. 15CPCh. 7.5 - Prob. 16CPCh. 7.5 - Prob. 17CPCh. 7.5 - Prob. 18CPCh. 7.8 - Prob. 19CPCh. 7.8 - Prob. 20CPCh. 7.8 - Write a set of nested loops that display the...Ch. 7.9 - Prob. 22CPCh. 7.9 - Prob. 23CPCh. 7.9 - Prob. 24CPCh. 7.9 - Prob. 25CPCh. 7.10 - Prob. 26CPCh. 7.10 - Prob. 27CPCh. 7.10 - Prob. 28CPCh. 7.10 - Prob. 29CPCh. 7.10 - Prob. 30CPCh. 7.10 - To create a bar chart with the bar function, what...Ch. 7.10 - Assume the following statement calls the bar...Ch. 7.10 - Prob. 33CPCh. 7 - This term refers to an individual item in a list....Ch. 7 - This is a number that identifies an item in a...Ch. 7 - Prob. 3MCCh. 7 - This is the last index in a list. a. 1 b. 99 c. 0...Ch. 7 - This will happen if you try to use an index that...Ch. 7 - This function returns the length of a list. a....Ch. 7 - When the operator's left operand is a list and...Ch. 7 - This list method adds an item to the end of an...Ch. 7 - This removes an item at a specific index in a...Ch. 7 - Prob. 10MCCh. 7 - If you call the index method to locate an item in...Ch. 7 - Prob. 12MCCh. 7 - This file object method returns a list containing...Ch. 7 - Which of the following statement creates a tuple?...Ch. 7 - Prob. 1TFCh. 7 - Prob. 2TFCh. 7 - Prob. 3TFCh. 7 - Prob. 4TFCh. 7 - A file object's writelines method automatically...Ch. 7 - You can use the + operator to concatenate two...Ch. 7 - Prob. 7TFCh. 7 - You can remove an element from a tuple by calling...Ch. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - What will the following code display? values = [2,...Ch. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 1AWCh. 7 - Prob. 2AWCh. 7 - Prob. 3AWCh. 7 - Prob. 4AWCh. 7 - Write a function that accepts a list as an...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Total Sales Design a program that asks the user to...Ch. 7 - Prob. 2PECh. 7 - Rainfall Statistics Design a program that lets the...Ch. 7 - Prob. 4PECh. 7 - Prob. 5PECh. 7 - Larger Than n In a program, write a function that...Ch. 7 - Drivers License Exam The local driver s license...Ch. 7 - Name Search If you have downloaded the source code...Ch. 7 - Prob. 9PECh. 7 - World Series Champions If you have downloaded the...Ch. 7 - Prob. 11PECh. 7 - Prob. 12PECh. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Expense Pie Chart Create a text file that contains...Ch. 7 - 1994 Weekly Gas Graph In the student sample...
Knowledge Booster
Similar questions
- (Numerical) Write an assignment statement to calculate the nth term in an arithmetic sequence. This is the formula for calculating the value, v, of the nth term: v=a+(n1)d a is the first number in the sequence. d is the difference between any two numbers in the sequence.arrow_forward(Conversion) Write a C++ program to convert kilometers/hr to miles/hr. The program should produce a table of 10 conversions, starting at 60 km/hr and incremented by 5 km/hr. The display should have appropriate headings and list each km/hr and its equivalent miles/hr value. Use the relationship that 1 kilometer=0.6241miles.arrow_forwardDesign a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.arrow_forward
- (Desk check) List the elements displayed by the following sections of code: a.for( m=1;m=5;m++)couta[m];b.for( k=1;k=5;k=k+2)couta[k];c.for( j=3;j=10;j++)coutb[j];d.for( k=3;k=12;k=k+3)coutb[k];e.for( i=2;i11;i=i+2)coutc[i];arrow_forward18. Tom and Jerry opened a new lawn service. They provide three types of services: mowing, fertilizing, and planting trees. The cost of mowing is $35.00 per 5,000 square yards, fertilizing is $30.00 per application, and planting a tree is $50.00. Write an algorithm that prompts the user to enter the area of the lawn, the number of fertilizing applications, and the number of trees to be planted. The algorithm then determines the billing amount. (Assume that the user orders all three services.) (9)arrow_forwardOption #1: String Values in Reverse Order Assignment Instructions Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method. In the main method, prompt the user for the three strings.arrow_forward
- Overview Create a program that starts with a list of movies, prompts a user to enter their favorite movie, and reacts differently whether or not it's in the list. Expected Output Sample 1 What is your favorite movie? Adventures in Babysitting Never heard of it. Sample 2 What is your favorite movie? Batman Great choicearrow_forwardPYTHON PROGRAMMING LANGUAGE Create a new text document called names.txt (this is done by hand - not using programming) with the following names: Adam, Bryan, Charlie. Each name should be followed by a hard return (do not store them in a list). Main Function. Write a program where the user enters a name. Using the read function, check to see if the name is in the text document. If it is, respond back to the user the name is found within the list. Read Function. The read function should return the contents of the text document as a list. Write Function. The write function should take the list and override the file with the new names list in reverse alphabetical order with a hard return after each name. EXAMPLEPlease enter a name: AdamAdam is found in the list.Enter another name (Y/N): YPlease enter a name: AndrewSorry, Andrew was not found in the list. Would you like to add it? (Y/N): YAndrew has been added to the list.Enter another name (Y/N): N LIST EXAMPLEadambryancharlie Final…arrow_forwardSales Data Program Create a successful running c++ program that meets the following requirements. Create a list to store the sales data for each month of the year with a three-letter abbreviation for the month to use as the key for each item. Make sure the program includes the add, total, edit, and view commands. If the user inputs the add command then it should ask which month they want to add sales data to, and then add it for that month. If the user inputs edit for the command then they should be able to edit the sales data for a three-letter month. If the user inputs total, then it should display the average and calculate all of the sales data inputted from the user. Use a display command to view the sales data for any three-letter month the user inputsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning