Question

Write a python program that generates a list of 50 random numbers. The program should display...

Write a python program that generates a list of 50 random numbers. The program should display (with labels) the sum, average, largest, and smallest of the list along with the list before and after sorting. Bonus: Find the mode (if any)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
from random import randint


total = 0
min_value = None
max_value = None
lst = []
for i in range(50):
    num = randint(1, 100)       # generates random numbers between 1 and 100.
    if i == 0:
        min_value = num
        max_value = num
    if num < min_value:
        min_value = num
    if num > max_value:
        max_value = num
    total += num
    lst.append(num)

print('sum:', total)
print('average:', total/50)
print('largest:', max_value)
print('smallest:', min_value)


print('List before sorting: ' + str(lst))
lst.sort()
print('Sorted list: ' + str(lst))
Add a comment
Know the answer?
Add Answer to:
Write a python program that generates a list of 50 random numbers. The program should display...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • home / study / engineering / computer science / computer science questions and answers / write...

    home / study / engineering / computer science / computer science questions and answers / write a python program that generates a list of 50 random numbers. the program should display ... Question: Write a python program that generates a list of 50 random numbers. The program should display (wi... Write a python program that generates a list of 50 random numbers. The program should display (with labels) the sum, average, largest, and smallest of the list along with the...

  • Write a program in python that generates X random integers Num. Num is a random number...

    Write a program in python that generates X random integers Num. Num is a random number between 20 to 50. X is a random number between 10 to 15. Calculate and show the Smallest, Largest, Sum, and Average of those numbers. You are not allowed to use Python functions sample(), min(), max(), average(), sort(), sorted()!! HINTs: to find Smallest.... 1) X is a random number between 10 to 15... for example 11...this determines how many times the loop will happen...

  • Can you help me write a Python 3.7 code for this question? Write a program using...

    Can you help me write a Python 3.7 code for this question? 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...

  • Python Code Write a program using functions and mainline logic which prompts the user to enter...

    Python Code Write a program using functions and mainline logic which prompts the user to enter a number. The number must be at least 5 and at most 20. (In other words, between 5 and 20, inclusive.) The program then generates that number of random integers and stores them in a list. The random integers should range from 0 to 100. (You can use a wider range if you want, but the lower end of the range must be at...

  • Write a program which gives an easy mathematics quiz. The program should display two random numbers...

    Write a program which gives an easy mathematics quiz. The program should display two random numbers which are to be added together, like this: 117 + 213 ----- The program should ask the user to enter their answer. If the answer is correct, the user should be congratulated. If the answer is wrong, the right answer should be displayed and the user should be scolded. Don't forget to: Generate random numbers Ask the user if they want to be tested...

  • A. Create a java program that generates 1000 random integers. Write the 1000 random integers to...

    A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.

  • How to write python code that is a dice rolling function that generates random numbers. The...

    How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...

  • Write a C++ program to read four whole numbers (integers) and perform the following (1) Display...

    Write a C++ program to read four whole numbers (integers) and perform the following (1) Display the largest of the numbers (2) Display the smallest of the numbers (3) Display sum of the even numbers (4) Display number of even and odd numbers

  • USING A PYTHON Write a program that gives simple math quizzes. The program should display two...

    USING A PYTHON Write a program that gives simple math quizzes. The program should display two random numbers that are to be added, such as: 247 + 129 The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT