Professional Documents
Culture Documents
CLASS: X
Register No.
Principal Teacher-in-Charge
External: Internal:
Date: Date:
CONTENTS
SOURCE CODE:
print("Enter the marks obtained in 5 subjects")
mOne=int(input("Enter the marks in Math:"))
mTwo=int(input("Enter the marks in Science:"))
mThree=int(input("Enter the marks in Social studies:"))
mFour=int(input("Enter the marks in English:"))
mFive=int(input("Enter the marks in Tamil/Hindi:"))
sum=mOne+mTwo+mThree+mFour+mFive
avg=sum/5
print("Average Mark is",avg)
OUTPUT:
2. Python program swap two variables.
SOURCE CODE:
P=int(input("Please enter the value for P:"))
Q=int(input("Please enter the value for Q:"))
temp=P
P=Q
Q=temp
print("The value of P after swapping:",P)
print("The value of Q after swapping:",Q)
OUTPUT:
3. Python program to calculate the simple interest and compound interest.
SOURCE CODE:
OUTPUT:
4. Python program to find the greater number.
AIM: To write a Python programto find the greater number out of the given
three numbers.
SOURCE CODE:
n1=int(input("Enter the first number:"))
n2=int(input("Enter the second number:"))
n3=int(input("Enter the third number:"))
if n1>n2 and n1>n3:
print(n1,"is greater")
elif n2>n1 and n2>n3:
print(n2,"is greater")
elif n3>n1 and n3>n2:
print(n3,"is greater")
else:
print("All are equal")
OUTPUT:
5. Python program to check whether a number is positive, negative or zero.
SOURCE CODE:
a=int(input("Enter the number:"))
if a>0:
print("The number given is positive")
elif a<0:
print("The number given is negative")
else:
print("The number is zero")
OUTPUT:
6. Python program to find the first 5 multiples of 8.
SOURCE CODE:
num=int(input(“Enter the number:”))
for i in range(1, 6):
print(num, 'x', i, '=', num*i)
OUTPUT:
7. Python program to find a factorial of a number.
SOURCE CODE:
n=int(input("Enter the number:"))
factorial = 1
if n>=1:
for i in range(1,n+1):
factorial=factorial*i
print("Factorial of the given number is:",factorial)
OUTPUT:
8. Python program to print a whole list, add, delete and remove a student
[
name.
AIM:To Write a Python program to print a whole list, add, delete and remove
a student name
SOURCE CODE:
mylist=["Anu","Banu","Hema"]
print(mylist)
mylist.append("Balu")
print("List after after append:")
print(mylist)
mylist =["Anu","Banu","Hema","Balu"]
mylist.remove("Anu")
print("List after removing an element:")
print(mylist)
mylist=["Anu”,”Banu","Hema"]
mylist.pop(0)
print(mylist)
OUTPUT:
9. Create a list of 10 numbers and perform the following few tasks:
SOURCE CODE:
mylist=[23,45,34,46,7,3,78,9,34,15]
print(len(mylist))
mylist=[23,45,34,46,7,3,78,9,34,15]
print(mylist[2:5])
mylist=[23,45,34,46,7,3,78,9,34,15]
print(mylist[-5:-2])
mylist=[23,45,34,46,7,3,78,9,34,15]
mylist.sort()
print(mylist)
OUTPUT:
10. Python program to add the elements of two lists.
SOURCE CODE:
List1=[1,2,3]
List2=[2,4,6]
List3=[]
print("List1 value",List1)
print("List2 value",List2)
for n in range(0,len(List1)):
List3.append(List1[n]+List2[n])
print("Sum of two lists",List3)
OUTPUT:
11. Python program to calculate mean, median and mode.
SOURCE CODE:
import numpy
from scipy import stats
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.mean(speed)
print("MEAN",x)
y = numpy.median(speed)
print("MEDIAN",y)
z = stats.mode(speed, keepdims=”true”)
print("MODE",z)
OUTPUT:
12. Python programto display line chart.
SOURCE CODE:
importmatplotlib.pyplot as plt
Grade=[1,2,3,4,5]
mark1=[80,90,98,78,86]
mark2=[54,65,76,87,98]
plt.title('AVERAGE MARK DISTRIBUTION CLASSWISE')
plt.plot(Grade,mark1,linewidth=3,color='cyan',label='MARKS1',linestyle='da
shed')
plt.plot(Grade,mark2,linewidth=3,color='r',label='MARKS2')
plt.xlabel('Class')
plt.ylabel('Average marks')
plt.legend(loc='lower right')
plt.show()
OUTPUT:
13. Python program to display a scatter chart.
SOURCE CODE:
import matplotlib.pyplot as plt
Sales=[510,350,475,580,600]
Month=['January','February','March','April','May']
plt.title('The Monthly Sales Report')
plt.scatter(Month,Sales,linewidth=3,color='blue',linestyle='dashed',label='Re
port')
plt.plot(Month,Sales,linewidth=3,color='blue',linestyle='dashed',label='Repo
rt')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend(loc='lower right')
plt.show()
OUTPUT:
14. Python program to read csv file saved in our system and display its
information.
AIM:ToWrite a Python program to read csv file saved in our system and
display its information.
SOURCE CODE:
import pandas as pd
dataset = pd.read_csv(r'C:\Users\Administrator\Desktop\trial.csv')
print(dataset)
OUTPUT:
15. Python program to read an image, display and identify its shape using
Python.
AIM: ToWrite a Python program toread animage, display and identify its
shape using Python.
SOURCE CODE:
importmatplotlib.image as mpimg
importmatplotlib.pyplot as plt
img = mpimg.imread(r'C:\Users\Administrator\Pictures\im1.jpg')
plt.imshow(img)
print(img.shape)
OUTPUT: