Question

In: Computer Science

Number Analysis Program (Specific Design Specifications) Design a Python program that asks the user to enter...

Number Analysis Program (Specific Design Specifications)

Design a Python program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list then display the following data: The lowest number in the list The highest number in the list The total of the numbers in the list The average of the numbers in the list

This python program must include the following functions. Your program must use the exact names, parameter lists, and follow the function descriptions provided.

def CreateNumberList(howMany): This function will accept a parameter for how many numbers to include in a list. It will create a list containing howMany elements that are random numbers in the range 1 - 500. The function return value will be the list that contains these values.

def SortList(myList): This function will accept the list of random numbers as the parameter variable. It will first use the sort() function to sort the values in the list. Then this function will use index 0 and index len(myList) - 1 to print the smallest and largest value in the list. This function does not have a return value.

def DisplayAverage(myList): This function will accept the list of random numbers as the parameter variable. If will use a for loop to iterate through each item in the list and add each value to a sum variable. You will then calculate the average of the values and display the average as the output. This function does not have a return value.

def main(): This function will begin by asking the user how many numbers they want to generate in their list. You must include an input validation loop that will not accept a number less than 1. After the input is validated, call the CreateNumberList function and store the return value in a variable, then call the SortList and DisplayAverage functions passing your list as an argument. Call your main function to execute the program.

Solutions

Expert Solution

Answer : please up vote or comment for any query i will update the same .Thanks

Note : check attached image for program and output

Program compiled and run in Python 3

Program :

import random #import random number package

def CreateNumberList(howmany): #get input to generate random number
  
List=[]
for x in range(howmany):#from 0 to howmany numbers
List.append(random.randint(1,65535)) #append one by one in list
return List #return list
  
  
def SortList(myList):
myList.sort()#sort the list
print("Smallest Number in List is :",myList[0]) #smallest number
print("Largest Number in List is :",myList[len(myList)-1]) #largest number
  
def DisplayAverage(myList):
sum=0
for i in myList:
sum+=i
print("Sum of numbers in list : ",sum) #sum of all numbers
length = len(myList) #number of element in list
print("Average of list number: ",sum/length) #ger average

  
  


  
def main():
number=0
number =int( input("Enter numbers to generate: "))#get number from user
while (number <1 or number >500): #check for number input
number =int( input("Enter numbers to generate: "))

List=CreateNumberList(number)
print("List is: ",List)#print list number
SortList(List)
DisplayAverage(List)
  

if __name__ == '__main__':
main() #call main function

Output :

Program :


  


Related Solutions

PYTHON: Write a program that asks the user to enter a 10-character telephone number in the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663. This is my code, but I cannot figure out where to go from here. #set new number new_number = "" #split number split_num = phone.split("-") for char in split_num[1:2]:...
Write a python program which asks the user to enter a positive number that is greater...
Write a python program which asks the user to enter a positive number that is greater than 30 called, “num2” and then does the following: o 1) Print all numbers between 1 and “num2” that are divisible by 2 and 3. o 2) Print all numbers between 1 and “num2” that are either divisible by 6 or 7. o 3) Print all numbers between 1 and “num3” that is not divisible by 5
Design a Python program with a While loop that lets the user enter a number. The...
Design a Python program with a While loop that lets the user enter a number. The number should be multiplied by 10 and the result stored in a variable named "product". The loop should repeat as long as the product variable < 10. Anything not completely obvious to a newbie should be commented on as in line comments. Should be modulated and repeatable as well as there should be an invocation of the main routine at the end of the...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Design a program that asks the user for a number and the program computes the factorial...
Design a program that asks the user for a number and the program computes the factorial of that number and displays the result . Implement with two different modules - one that uses a for loop and one that uses a while loop Grading Rubrick Program Compiles Cleanly  syntax errors25 pts-5 per errorProgram runs without runtime errors ( validation)run-time errors 25 pts-5 per errorProgram give correct answersLogic errors30 pts-5 per errorProgram is repeatableNot repeatable5 pts-5 ptsProgram is well modularizedBarely Modularized10 pts-...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
Python. Write a code that asks the user to enter a string. Count the number of...
Python. Write a code that asks the user to enter a string. Count the number of different vowels ( a, e, i, o, u) that are in the string and print out the total. You may need to write 5 different if statements, one for each vowel. Enter a string: mouse mouse has 3 different vowels
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
Develop a program that asks a user to enter the number 10, and then it outputs...
Develop a program that asks a user to enter the number 10, and then it outputs COUNT-DOWN from 10 to 0. using for-loop
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT