0% found this document useful (0 votes)
13 views2 pages

Python Programming - 3 and 4

The document provides Python programming examples for calculating the mean, variance, and standard deviation of a list of numbers input by the user. It also includes a program that reads a multi-digit number and prints the frequency of each digit. The examples demonstrate basic list operations and mathematical calculations in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Python Programming - 3 and 4

The document provides Python programming examples for calculating the mean, variance, and standard deviation of a list of numbers input by the user. It also includes a program that reads a multi-digit number and prints the frequency of each digit. The examples demonstrate basic list operations and mathematical calculations in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Python Programming

3. Read n numbers from the console and create a list. Develop a python program to print
mean,variances and standard deviation with suitable messages.

import math
list=[]
N=int(input("Enter N="))
for i in range(N):
item=int(input())
[Link](item)

# Mean
sum=0
for i in list:
sum=sum+1
mean=sum/N
print("Mean=",mean)

# Variance
d=0
for i in list:
d=d+(i-mean)**2
var=d/N
print("Variance=",round(var,2))

# Standard Deviation
sd=[Link](var)
print("SD=",round(sd,2))

Output:

Enter N= 5
1
2
3
4
5
Mean= 1.0
Variance= 6.0
SD= 2.45
4. Read a multi-digit number (as characters) from the console. Develop a python program to print
the frequency of each digit with suitable message.

n=list(input("Enter multi-digit number = "))

u=set(n)

for i in u:

c=[Link](i)

print("Frequency of",i,"=",c)

Output:

Enter multi-digit number = 3453456342


Frequency of 6 = 1
Frequency of 4 = 3
Frequency of 2 = 1
Frequency of 5 = 2
Frequency of 3 = 3

You might also like