Python
Python
SCIENCE DEPARTMENT
STATISTICS AND ANALYTICS (PYTHON PROGRAMMING)
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
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