0% found this document useful (0 votes)
2 views

PYTHON - Record Programs

The document is a practical record for a skill education course in Artificial Intelligence at Chinmaya Vidyalaya, detailing various programming exercises. It includes programs on advanced Python, data science, and computer vision, with code examples and expected outputs. The record serves as a comprehensive guide for students to demonstrate their practical skills in these areas.

Uploaded by

Chocoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

PYTHON - Record Programs

The document is a practical record for a skill education course in Artificial Intelligence at Chinmaya Vidyalaya, detailing various programming exercises. It includes programs on advanced Python, data science, and computer vision, with code examples and expected outputs. The record serves as a comprehensive guide for students to demonstrate their practical skills in these areas.

Uploaded by

Chocoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

CHINMAYA VIDYALAYA

KOLAZHY- THRISSUR

SKILL EDUCATION
(ARTIFICIAL INTELLIGENCE-417)
PRACTICAL RECORD
Name :___________________________________________________

Class :____________ Roll No : ____________ Year ________________

Certify that this is the bonafide record of practical work done by

___________________________________________________________

with Rollno ______________________ in the year __________________

_______________________________________________________________

Date : Teacher in Charge

1|Page
INDEX
SL DATE CONTENTS PAGE
NO NO

Advance Python Programs


1 Program to calculate and print total marks and 3
average marks
2 Program to calculate area and Perimeter of Square 4
3 Program to accept any Character and print it’s type 4
4 Program to print the multiplication table of a number 5
5 Program to print the square of a range of numbers 5

Data Science Programs


1 Program to read an open csv file and display few rows 6
2 Program to read an open csv file and display the data 7
in the order of columns specified
3 Program to draw a line chart using matplotlib library 8
4 Program to draw a bar chart using matplotlib library 9
5 Program to draw a pie chart using matplotlib library 10

Computer Vision Programs


1 Program to display image using opencv cv2 library 11
2 Program to display image using opencv cv2 library in 12
RGB format
3 Program to display image using opencv cv2 library as 13
a gray scale image
4 Program to display minimum and maximum pixel value 14
of image using opencv cv2 library
5 Program to crop the image using opencv cv2 library 15

2|Page
Advance Python Programs
#1 WAP to accept Name and 5 Marks of a student and find and print the
Total marks and Average marks.
Program code
Name = input(“Enter Name of the Student=”)
M1 = float (input(“Enter the English Marks = “))
M2 = float (input(“Enter the Hindi Marks = “))
M3 = float (input(“Enter the Language Marks = “))
M4 = float (input(“Enter the Science Marks = “))
M5 = float (input(“Enter the Social Science Marks = “))
Total = M1+M2+M3+M4+M5
Avg=Total/5
print(“ Student Name = “,Name)
print(“ Total Marks =”,Total)
print(“Average Marks =”,Avg)
Output
Enter Name of the Student=Mahesh
Enter the English Mark=27
Enter the Hindi Mark = 32
Enter the Language Mark =45
Enter the Science Mark = 39
Enter the Social Science Mark =41

Student Name = Mahesh


Total Marks =184
Average Marks =36.8
*********

3|Page
#2 WAP to calculate the Area and Perimeter of a Square ( A= S*S , P = 4*S )
Program code
S = float (input(“Enter Side = “))
print(“Area of Square =”, S*S)
print (“Perimeter of a Square=”, 4*S)
Output
Enter Side =15
Area of Square =225
Perimeter of a Square=60
*******
#3 WAP to accept any Character and check whether it’s an special symbol,
Number, Uppercase character or Lowercase character .
Program Code
ch=input("Enter a Character:")
if ch>='A' and ch<='Z':
print ("You have entered a Upper case Character")
elif ch>='a' and ch<='z':
print ("You have entered a Lower case Character ")
elif ch>='0' and ch<='9':
print ("You have entered a Number")
else:
print("You have entered a Special symbol")
Output

Case 1 Case 2
Enter a Character:1 Enter a Character: q
You have entered a Number You have entered a Lower case Character
Case 3 Case 4
Enter a Character: Q Enter a Character: /
You have entered a Upper case Character You have entered a Special symbol
***********

4|Page
#4 WAP to print the multiplication table of a number.
Program Code
N=int(input("Enter the No="))
i=1
while(i<=10):
print (i,"*",N,"=",i*N)
i=i+1
print("End of Loop")
Output
Enter the No=7
1*7=7
2 * 7 = 14
.
.
.
9 * 7 = 63
10 * 7 = 70
End of Loop

*************

#5 WAP to print the square of N nos. (using for loops)


Program Code
N=int(input("Enter a Limit="))
for i in range(1,N+1,1):
print("Square of ",i,"=",i*i)
Output
Enter a Limit=5
Square of 1 = 1
Square of 2 = 4
Square of 3 = 9
Square of 4 = 16
Square of 5 = 25
**********

5|Page
Data Science Programs

#1 WAP to read an open csv file “JaipurFinalCleanData.csv” and to display


first ten rows of data .
Program Code
import pandas as pd
dataframe=pd.read_csv("JaipurFinalCleanData.csv")
print(dataframe.head(10))

Output

date meantempm maxtempm ... precipm_1 precipm_2 precipm_3


0 2016-05-04 34 41 ... 0.0 0.0 0.0
1 2016-05-05 31 38 ... 0.0 0.0 0.0
2 2016-05-06 28 34 ... 5.0 0.0 0.0
3 2016-05-07 30 38 ... 0.0 5.0 0.0
4 2016-05-08 34 41 ... 0.0 0.0 5.0
5 2016-05-09 34 42 ... 0.0 0.0 0.0
6 2016-05-10 34 41 ... 0.3 0.0 0.0
7 2016-05-11 32 40 ... 0.8 0.3 0.0
8 2016-05-12 34 42 ... 2.0 0.8 0.3
9 2016-05-13 34 42 ... 0.3 2.0 0.8

6|Page
#2 WAP to read an open csv file “JaipurFinalCleanData.csv” and sort first
two rows based on mean temperature in ascending order and date in
descending order .

Program Code
import pandas as pd
dataframe = pd.read_csv("JaipurFinalCleanData.csv")
jaipur_weather=dataframe.sort_values(by='meantempm',ascending=True)
print(jaipur_weather.head(2))
date=dataframe.sort_values(by='date',ascending=False)
print(date.head(5))

Output
date meantempm maxtempm ... precipm_1 precipm_2 precipm_3
252 2017-01-11 10 18 ... 0.0 0.0 0.0
253 2017-01-12 12 19 ... 0.0 0.0 0.0
[2 rows x 40 columns]
date meantempm maxtempm ... precipm_1 precipm_2 precipm_3
675 2018-03-11 26 34 ... 0.0 0.0 0.0
674 2018-03-10 26 34 ... 0.0 0.0 0.0
673 2018-03-09 26 33 ... 0.0 0.0 0.0
672 2018-03-08 24 32 ... 0.0 0.0 0.0
671 2018-03-07 24 32 ... 0.0 0.0 0.0

[5 rows x 40 columns]

7|Page
#3 WAP to draw a line chart using matplotlib library .
Program Code
import matplotlib.pyplot as plt
import numpy as np
marks=np.array([70,85,65,90,95])
subjects=["English","Maths", "Science","Social Science" , "AI"]
plt.plot(subjects,marks,color="r", marker="*",markeredgecolor="blue")
plt.xlabel("Subject Names" ,fontsize=14)
plt.ylabel("Marks" , fontsize=14)
plt.title("Line Graph of Student's Performance")
plt.show()

Output

8|Page
#4 WAP to draw a bar chart using matplotlib library .
Program Code
import matplotlib.pyplot as plt
import numpy as np
marks=np.array([70,85,65,90,95])
subjects=["English","Maths", "Science","Social Science" , "AI"]
plt.bar(subjects,marks,color=["orange","red","blue","yellow","green"])
plt.xlabel("Subject Names" ,fontsize=14)
plt.ylabel("Marks" , fontsize=14)
plt.title("Bar Graph of Student's Performance")
plt.show()
Output

9|Page
#5 WAP to draw a pie chart using matplotlib library .
Program Code
import matplotlib.pyplot as plt
import numpy as np
marks=np.array([70,85,65,90,95])
subjects=["English","Maths", "Science","Social Science" , "AI"]
colors=["orange","red","blue","yellow","green"]
explode=[0,0,0,0,0.2]
plt.pie(marks,labels=subjects,colors=colors,explode=explode,shadow=True)
plt.title("Pie Chart of Student's Performance")
plt.show()

Output

10 | P a g e
Computer Vision Programs
#1 WAP to store the pixel values in the Numpy array and to display image
using opencv cv2 library .
Program Code
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("flower.png")
plt.imshow(img)
plt.title("Image")
plt.axis('off')
plt.show()
Output

11 | P a g e
#2 WAP to store the pixel values in the Numpy array and to display image
using opencv cv2 library in RGB format.
Program Code
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("flower.png")
plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
plt.title("Image")
plt.axis('off')
plt.show()

Output

12 | P a g e
#3 WAP to store the pixel values in the Numpy array and to display image
using opencv cv2 library as a gray scale image.
Program Code
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("flower.png",0)
plt.imshow(img,cmap='gray',interpolation='bicubic')
plt.title("Image")
plt.axis('off')
plt.show()

Output

13 | P a g e
#4 WAP to display minimum and maximum pixel value present in the image
using opencv cv2 library .
Program Code
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("flower.png")
print("Minimum pixel value = ",img.min())
print("Maximum pixel value = ",img.max())

Output

Minimum pixel value = 0

Maximum pixel value = 255

14 | P a g e
#5 WAP to crop the image using opencv cv2 library .
Program Code
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("flower.png")
roi=img[10:425,10:425]
plt.imshow(cv2.cvtColor(roi,cv2.COLOR_BGR2RGB))
plt.title("Cropped Image")
plt.axis('off')
plt.show()

Output

15 | P a g e

You might also like