Computer Science
Write a program that generates six random numbers in a sequence created with (start, stop, step). Then print the mean, median and mode of the generated numbers.
Python
Python Data Handling
35 Likes
Answer
import random
import statistics
start = int(input("Enter start: "))
stop = int(input("Enter stop: "))
step = int(input("Enter step: "))
a = random.randrange(start, stop, step)
b = random.randrange(start, stop, step)
c = random.randrange(start, stop, step)
d = random.randrange(start, stop, step)
e = random.randrange(start, stop, step)
f = random.randrange(start, stop, step)
print("Generated Numbers:")
print(a, b, c, d, e, f)
seq = (a, b, c, d, e, f)
mean = statistics.mean(seq)
median = statistics.median(seq)
mode = statistics.mode(seq)
print("Mean =", mean)
print("Median =", median)
print("Mode =", mode)
Output
Enter start: 100
Enter stop: 500
Enter step: 5
Generated Numbers:
235 255 320 475 170 325
Mean = 296.6666666666667
Median = 287.5
Mode = 235
Answered By
17 Likes
Related Questions
Write a program whose three sample runs are shown below:
Sample Run 1:
Random number between 0 and 5 (A) : 2
Random number between 0 and 5 (B) :5.
A to the power B = 32Sample Run 2:
Random number between 0 and 5 (A) : 4
Random number between 0 and 5 (B) :3.
A to the power B = 64Sample Run 3:
Random number between 0 and 5 (A) : 1
Random number between 0 and 5 (B) :1.
A to the power B = 1Write a program that inputs an age and print age after 10 years as shown below:
What is your age? 17
In ten years, you will be 27 years old!Write a program to generate 3 random integers between 100 and 999 which is divisible by 5.
Write a program to generate 6 digit random secure OTP between 100000 to 999999.