PYTHON PROGRAMMING (1BPLC105B) LAB COMPONENT
3. a. Read N numbers from the console and create a list. Develop a program to print mean,
variance and standard deviation with suitable messages.
SOURCE CODE:
import math
list_num = list()
N = int(input(("Enter the value of N: ")))
print("Enter {0} numbers".format(N))
for i in range(1,N+1):
num = int(input())
list_num.append(num)
print("The entered list of numbers is : ",list_num)
# Finding sum of numbers in list
sum = 0
for num in list_num:
sum = sum + num
print("The sum of numbers in the list is : ",sum)
# To find the mean of numbers in list
mean = sum/len(list_num)
print("Mean of numbers in the list is : ",mean)
# To find variance of numbers in list
sum_var = 0
for num in list_num:
sum_var = sum_var + (num -mean)**2
variance = sum_var/N
print("Variance of numbers in the list is : ",variance)
# To find the standard deviation of numbers in list
std = [Link](variance)
print("The standard deviation of numbers in list is : ",std)
Screenshot of Code:
Sample Ouput:
3. b. Read a multi-digit number (as chars) from the console. Develop a program to print the
frequency of each digit with a suitable message.
SOURCE CODE:
number =int(input("Enter any Multidigit Number : "))
print("Digit\tFrequency")
for i in range(0,10):
count = 0
temp = number
while temp > 0:
digit = temp % 10
if digit == i:
count = count + 1
temp = temp // 10
if count > 0:
print(i,"\t",count)
Screenshot of code:
Sample Output: