Question

In: Computer Science

Write a Python program with correct indentation using functions and mainline logic which prompts the user...

Write a Python program with correct indentation using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user:

  • The list of integers
  • The lowest number in the list
  • The highest number in the list
  • The total sum of all the numbers in the list
  • The average number in the list
  • At a minimum, the numbers should range from 0 to 50, but you can use any range you like.

Solutions

Expert Solution

main.py

import random

n = int(input("Enter a number: "))
randNumList = []
for i in range(0, n):
randNum = random.randint(0,100)
randNumList.append(randNum)
  
print("Numbers:",randNumList)
print("The lowest number in the list =",min(randNumList))
print("The highest number in the list =",max(randNumList))
print("The total sum of all the numbers in the list =",sum(randNumList))
print("The average number in the list =",sum(randNumList)/n)

Code Snippet (For Indentation):

Output:


Related Solutions

Write a Python program using functions and mainline logic which prompts the user to enter a...
Write a Python program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a file. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The average number in the list At a minimum, the numbers should...
Do it in python please Write a program using functions and mainline logic which prompts the...
Do it in python please Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The average number in the list At a...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
Write a Python program which prompts the user to input a string. Then, print the string...
Write a Python program which prompts the user to input a string. Then, print the string in reverse to the terminal Sample output Please enter a word: "zeus" The reverse of zeus is suez Hint: There are several ways to accomplish this. Recall that a string is an itterable object and therefore can be used with a for loop
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user...
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message...
USING PYTHON ONLY Part 3a: Prime Number Finder Write a program that prompts the user to...
USING PYTHON ONLY Part 3a: Prime Number Finder Write a program that prompts the user to enter in a postive number. Only accept positive numbers - if the user supplies a negative number or zero you should re-prompt them. Next, determine if the given number is a prime number. A prime number is a number that has no positive divisors other than 1 and itself. For example, 5 is prime because the only numbers that evenly divide into 5 are...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score. Hint: Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument...
Python A program which prompts the user to enter an number which is a integer n...
Python A program which prompts the user to enter an number which is a integer n and creates a tuple where the values are all numbers between 1 and n (both inclusive). Note: you can assume that the integer will always be > 1. Input Result 3 Enter an integer: 3 (1, 2, 3)
Write a program which prompts the user for the year of their birth, and which then...
Write a program which prompts the user for the year of their birth, and which then calculates their age (ignoring the month/day). Split the program into `main`, a "prompt for year" function which tests to make sure the user's input is a valid year, and a "calculate age" function which performs the actual calculation. (You can assume the current year is 2017.) for my intro to c++ class
Write a program which: Prompts the user for a positive integer >= 0 Validates the user...
Write a program which: Prompts the user for a positive integer >= 0 Validates the user input to ensure it is a positive integer >= 0 Allocate (dynamically) an array big enough for the data. Load the array with random numbers ranging in value from1 to 100 Display the elements of the array (unsorted) Display the elements of the array (sorted) Display the average Display the median Display the mode, if none, display appropriate message RESTRICTIONS No global variables No...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT