Write a python code that calculates the mean and median of a sample of 100 uniform random numbers between 0 and 2 and the percentage of points in the sample that are greater than 1.
Required Python Code:
import random
import numpy
def Rand(start, end, num):
res = []
for j in range(num):
res.append(random.uniform(start, end))
return res
res = Rand(0, 2, 100)
print("Mean of 100 random uniform numbers between 0 and 2 is ", numpy.mean(res))
print("Median of 100 random uniform numbers between 0 and 2 numbers is ", numpy.median(res))
percentage = 0
for i in res :
if i > 1 :
percentage = percentage + 1
print("Percentage of numbers greater than 1 is ", percentage, "%")
SAMPLE OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.