121k views
17 votes
Design and implement an application that reads a set of values in the range 1 to 100 from the user and then creates a chart showing how often the values appeared

1 Answer

6 votes

Answer:

import random

import matplotlib.pyplot as plt

n = int(input("Enter the number of values: "))

mylist = random.choices(range(1,100), k= n)

plt.hist(mylist, bins=[1,10,20,30,40,50,60,70,80,90,100])

plt.xlabel(" Numbers")

plt.ylabel(" Frequency")

plt.show()

Step-by-step explanation:

The python progam creates an histogram where the x axis is a list of random numbers in the range of 1 to 100. The program uses the random and matplotlib packages. The random module is used to get the a list of randomly selected values from a range of 1 to 100 and the matplotlib denoted as plt is use to plot a chart of the list as the x-axis and the frequency of the number values in the list.

User Merrydeath
by
7.3k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.