Professional Documents
Culture Documents
a) Write a python program to create a list of random numbers in normal distribution and display
the frequency of each value
start = 0
end = 1
num_values = 20
random_numbers = [round(num, 2) for num in random_numbers] #round will round off number
frequency_counter = Counter(random_numbers)
print("Value \tFrequency")
print("------------------")
for value, frequency in frequency_counter.items():
print(f"{value}\t{frequency}")
Value Frequency
------------------
0.46 2
0.54 1
0.32 1
0.05 2
0.85 2
0.95 1
0.34 1
0.13 2
0.68 1
0.42 1
0.83 1
0.31 1
0.69 1
0.89 1
0.09 1
0.21 1
b) Write a python program to print the odd and even numbers from a given range taken as per
user's input and display the prime numbers from the first 20 odd numbers.
def check_prime(n):
divisors = 0
for i in range(1, int((n + 1) / 2) + 1):
if n % i == 0:
divisors += 1
for i in range(start,end):
if i % 2 == 0:
even.append(i)
else:
odd.append(i)
print("List of even numbers from ", start, " to", end, " : ", even)
print("List of Odd Numbers from ", start, " to", end, " : ", odd)
print("List of First ", end ," Prime numbers from ", start, " to", end, " : ", prime)
c) Write a python program to read any .csv file as per user-provided input and display its
content.