Python | PDF | Standard Deviation | Variance
0% found this document useful (0 votes)
5 views

Python

For the

Uploaded by

rmzakash61
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python

For the

Uploaded by

rmzakash61
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GOVERNMENT POLYTECHNIC, VIJAYAPUR

SCIENCE DEPARTMENT
STATISTICS AND ANALYTICS (PYTHON PROGRAMMING)

#Expt 19 To write a python program to convert Decimal to Binary, Octal and


Hexedecimal
dec=int(input("Enter a decimal Number: "))
print(bin(dec), "in binary.")
print(oct(dec),"in octal.")
print(hex(dec),"in hexadcimal.")

OUTPUT
Enter a decimal Number: 256
0b100000000 in binary.
0o400 in octal.
0x100 in hexadcimal.

#Expt 20 To write a python program to add two integers and 2 strings and print the
result
num1=int(input("Enter the first number: "))
num2=int(input("Enter the second number: "))
num=num1+num2
print("Sum of two given numbers is : ",num)
str1=str(input("Enter the first string: "))
str2=str(input("Enter the second string: "))
str=str1+str2
print("Addition of two given strings is : ",str)

OUTPUT
Enter the first number: 125
Enter the second number: 350
Sum of two given numbers is : 475
Enter the first string: GPT
Enter the second string: Vijayapur
Addition of two given strings is : GPTVijayapur
#Expt 21 To write a python program to find the sum of first 10 natural numbers.
n=10
sum1=0
while(n>0):
sum1=sum1+n
n=n-1
print(" The sum of first 10 natural numbers is : ",sum1)

OUTPUT
The sum of first 10 natural numbers is : 55

#Expt 22 To write a python program to find whether the number is odd or even.
num=int(input("Enter any number : "))
flag=num%2
if flag==0:
print(num, "is an even number")
elif flag==1:
print(num, "is an odd number")
else:
print("Error, Invalid number")

OUTPUT
Enter any number : 25
25 is an odd number

Enter any number : 46


46 is an even number
#Expt 23 Write a python program to find the variance and standard deviation for the
given data.
import statistics
data=[15,28,18,9,46,27,25,47,76,45]#Take list of elements
var=statistics.pvariance(data)
print("Variance is : ",var) #Calculating variance using var()
sd=statistics.pstdev(data)
print("Variance is : ",sd) #Calculating sttandard deviation using std()

OUTPUT
Variance is : 360.44
Variance is : 18.985257438338834

#Expt 24 To write a python to enter the marks of the student across the subject.
s1=int(input("Student marks in Mathematics : "))
s2=int(input("Student marks in EVS : "))
s3=int(input("Student marks in Statistics : "))
s4=int(input("Student marks in Kannada : "))
s5=int(input("Student marks in Communication Skills : "))
print("Marks in Mathematics= ",s1)
print("Marks in EVS= ",s2)
print("Marks in Statistics= ",s3)
print("Marks in Kannada= ",s4)
print("Marks in Communication Skills= ",s5)
Total=s1+s2+s3+s4+s5
Percentage=Total/5
print("Total Marks scored by the student= ",Total)
print("Percentage of marks= ",Percentage)

OUTPUT
Student marks in Mathematics : 56
Student marks in EVS : 58
Student marks in Statistics : 56
Student marks in Kannada : 47
Student marks in Communication Skills : 59
Marks in Mathematics= 56
Marks in EVS= 58
Marks in Statistics= 56
Marks in Kannada= 47
Marks in Communication Skills= 59
Total Marks scored by the student= 276
Percentage of marks= 55.2

#Expt 25 To write a python to create a labelled bar graph using matplotlib. pyplot
import matplotlib.pyplot as plt

x=[10,20,30,40,50]
y=[58,49,42,26,36]

plt.bar(x,y,label='Bars')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Bar Graph')
plt.legend()
plt.show()

#Expt 26 To write a python to create a labelled pie graph using matplotlib. pyplot

from matplotlib import pyplot as plt


import numpy as np
fig=plt.figure()
ax=fig.add_axes([0,0,1,1])
ax.axis('equal')
languages=['C','C++','JAVA','PYTHON','PHP']
students=[25,23,24,19,28]
ax.pie(students,labels=languages,autopct='%1.2f%%')
plt.show()

You might also like