0% found this document useful (0 votes)
3 views5 pages

Final Practical File - To Upload

The document contains a series of Python programs that demonstrate various functionalities including calculating sums and averages, swapping variables, computing simple and compound interest, finding the greater number among three inputs, checking if a number is positive, negative, or zero, and performing list operations. Additional programs include generating multiples, calculating factorials, manipulating lists, performing statistical calculations, and visualizing data through line and scatter charts. It also includes examples of reading CSV files and images using Python libraries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Final Practical File - To Upload

The document contains a series of Python programs that demonstrate various functionalities including calculating sums and averages, swapping variables, computing simple and compound interest, finding the greater number among three inputs, checking if a number is positive, negative, or zero, and performing list operations. Additional programs include generating multiples, calculating factorials, manipulating lists, performing statistical calculations, and visualizing data through line and scatter charts. It also includes examples of reading CSV files and images using Python libraries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. Python program to find the sum and average mark of 5 subjects.

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(“The total is”, sum)
print("Average Mark is",avg)

2. Python program swap two variables.


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)

3. Python program to calculate the simple interest and compound interest.


principal = float(input('Enter the Principal amount: '))
time = float(input('Enter time in years: '))
rate = float(input('Enter rate interest per annum: '))
n = float(input("Enter the number times CP is applied per time period "))
simple_interest = (principal*time*rate)/100
compound_interest = principal*(1+rate/n)**(n*time)-principal
print("Simple interest is:", simple_interest)
print("Compound interest is:",compound_interest)
4. Python program to find the greater number.
num1=int(input("Enter the first number:"))
num2=int(input("Enter the second number:"))
num3=int(input("Enter the third number:"))
if num1>num2 and num1>num3:
print(num1,"is greater")
elif num2>num1 and num2>num3:
print(num2,"is greater")
elif num3>num1 and num3>num2:
print(num3,"is greater")
else:
print("All are equal")

5. Python program to check whether a number is positive, negative or zero.


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")

6. Python program to find the first 5 multiples of 8.


num=int(input(“Enter the number:”))
for i in range(1, 6):
print(num, 'x', i, '=', num*i)

7. Python program to find a factorial of a number.


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)

8. Python program to print a whole list, add, delete and remove a student name.
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)
9. Create a list of 10 numbers and perform the following few tasks:

 Print the length of the list


 Print the elements from second to fourth using positive indexing.
 Print the elements from third to fifth using negative indexing.
 Sorting in ascending order.

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)
10. Python program to add the elements of two lists.
List1=[1,2,3]
List2=[2,4,6]
List3=[]
print("List1 value",List1)
print("List2 value",List2)
for i in range(0,len(List1)):
List3.append(List1[i]+List2[i])
print("Sum of two lists",List3)

11. Python program to calculate mean, median and mode.


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)

12. Python program to display line chart.


import matplotlib.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='dashed')
plt.plot(Grade,mark2,linewidth=3,color='r', label='MARKS2')
plt.xlabel('Class')
plt.ylabel('Average marks')
plt.legend(loc='lower right')
plt.show()

13. Python program to display a scatter chart.


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='Report')
plt.plot(Month,Sales,linewidth=3,color='blue',linestyle='dashed',label='Report')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend(loc='lower right')
plt.show()

14. Python program to read csv file saved in our system and display its information.
import pandas as pd
dataset = pd.read_csv(r'C:\Users\Administrator\Desktop\trial.csv')
print(dataset)

15. Python program to read an image, display and identify its shape using Python.

import matplotlib.image as mpimg


import matplotlib.pyplot as plt
img = mpimg.imread(r'C:\Users\Administrator\Pictures\im1.jpg')
plt.imshow(img)
print(img.shape)

You might also like