0% found this document useful (0 votes)
16 views28 pages

Class 10th AI...

The document is a practical file for the Artificial Intelligence subject, containing various programming exercises related to data visualization and basic computations using Python. It includes programs for creating different types of graphs, calculating sums, and manipulating images using libraries like Matplotlib and OpenCV. The file is submitted by a student named Harmeet Singh and includes a table of contents with corresponding page numbers for each program.

Uploaded by

Rawinder Singh
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)
16 views28 pages

Class 10th AI...

The document is a practical file for the Artificial Intelligence subject, containing various programming exercises related to data visualization and basic computations using Python. It includes programs for creating different types of graphs, calculating sums, and manipulating images using libraries like Matplotlib and OpenCV. The file is submitted by a student named Harmeet Singh and includes a table of contents with corresponding page numbers for each program.

Uploaded by

Rawinder Singh
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/ 28

S.D. MODEL SR. SEC. SCHOOL.

PracticalFile Of
Artificial
intelligence Subject
Code - 417
(Session-2023-24)

Submitted to: - Submitted by:-

Mrs. PriyaHanda Harmeet singh

10th daisy
TableofContents

S.No. Nameofprogram Page no.


1. Program to make the pie chart 1

2. Program to make the bar graph 2

3. Program .to find the uses of mobile 3


phone in different area
4. Program to make histogram 4
5. Program to making scatter graph 5

6. Program to make a line graph 6


7. Program to making a double line graph 7
8. Program to find the difference of prices 8

9. Program to print the sum natural no. 9

10. Program to print all items from a list 10


comtaining some colour name
11. Program to print table of a number,say5 11

12. Program to marks of different subjects 12

13. Program to square of first 5 natural 13


number
14. Program to input a number (num)and 14
print the sum
15. Program to calculate and print the sum 15
of even and odd integers of the first n
natural number
16. Program of Program to to input two 16
(first number n1 been less than second
number n2
17. Program to create original photo to blur 17
photo
18. Program to create the original photo to 18
sketch photo
19. Program to create the original photo to 19
bilateral photo
1)Program to make the pie chart.
import matplotlib.pyplot as plt
labels = ['Category A', 'Category B', 'Category C', 'Category D']
sizes = [25, 30, 20, 25]
colors = ['lightcoral', 'lightskyblue', 'lightgreen','red']
explode = (0.1, 0, 0, 0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()

Output :
2) Program to make the bar graph.
Import matplotlib.pyplot as plt
Categories = [‘Category A’, ‘Category B’, ‘Category C’, ‘Category
D’]
Values = [30, 45, 15, 25]
Plt.bar(categories, values, color=’skyblue’)
Plt.xlabel(‘Categories’)
Plt.ylabel(‘Values’)
Plt.title(‘Bar Chart Example’)
Plt.show()
3) Program to find the uses of mobile phone in different area.
Import matplotlib.pyplot as plt
Area= [‘iqbal nagar’, ‘gandhi nagar’, ‘shanti nagar’, ‘dalip nagar’]
Peopleuses = [30, 45, 15, 25]
Plt.bar(area, peopleuses, color=’red’)
Plt.xlabel(‘area’)
Plt.ylabel(‘people uses’)
Plt.title(‘mobile phone uses’)
Plt.show()

Output:
4)Program for making a histogram.
import matplotlib.pyplot as plt
import numpy as np
data = np.random.randn(1000)
plt.hist(data, bins=30, color='skyblue', edgecolor='black')
plt.xlabel('Values')
plt.ylabel('Frequency')
plt.title('Histogram Example')
plt.show()

Output:
5)program for making scatter graph.
Import matplotlib.pyplot as plt
Import numpy as np
X = np.random.rand(5)
Y = np.random.rand(5)
Plt.scatter(x, y, color=’green’, marker=’o’, label=’Scatter’)
Plt.xlabel(‘X-axis’)
Plt.ylabel(‘Y-axis’)
Plt.title(‘Scatter Plot ’)
Plt.legend()
Plt.show()

Output:
6)program to make line graph.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y, color='blue', linestyle='-', label='Line')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Graph')
plt.legend()
plt.show()

Output:
7) program for making double line graph.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
plt.plot(x, y1, color='blue', linestyle='-', label='Line 1')
plt.plot(x, y2, color='red', linestyle='--', label='Line 2')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Double Line Graph')
plt.legend()
plt.show()

output:
8) program to find the diffrances of prices.
Import matplotlib.pyplot as plt
Import numpy as np
Days = np.arange(1, 11)
Price_stock1 = np.random.randint(50, 100, size=10)
Price_stock2 = np.random.randint(40, 90, size=10)
Price_difference = price_stock1 – price_stock2
Plt.plot(days, price_stock1, label=’Stock 1’, marker=’o’)
Plt.plot(days, price_stock2, label=’Stock 2’, marker=’o’)
Plt.plot(days, price_difference, label=’Price Difference’,
linestyle=’—‘, marker=’o’)
Plt.xlabel(‘Days’)
Plt.ylabel(‘Prices’)
Plt.title(‘Double Line Graph – Price Difference’)
Plt.legend()
Plt.show()
9)Program to print the sum of natural numbers.
sum=0
for n in range(1,8):
sum+=n
print("sum of natural numbers<=",n,"is",sum)

Output:

sum of natural numbers<= 1 is 1


sum of natural numbers<= 2 is 3
sum of natural numbers<= 3 is 6
sum of natural numbers<= 4 is 10
sum of natural numbers<= 5 is 15
sum of natural numbers<= 6 is 21
sum of natural numbers<= 7 is 28
10)Program to print all items from a list containing some
colours names.
colist=["blue","green","yellow","orange","red","brown"]
for colname in colist:
print(colname)

Output:

blue
green
yellow
orange
red
Brown
11)Program to print table of a number, say5.
num=5
for i in range(1,11):
print(num,'x',i,'=',num*i)

Output:

5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5x 10 = 50
12)Program to print total marks of different subjects.
marks=[98,79,69,71,65]
print("marks are:",marks)
total=0
for sm in marks are: [98, 79, 69, 71, 65]
total=total+sm
print("the total marks are:",total)

Output:

marks are: [98, 79, 69, 71, 65]


the total marks are: 382
13)Program to print square of first 5 natural numbers.
num=1
while num<=5:
print(num*num)
num=num+1

Output:

1
4
9
16
25
14) Program to input a number(num) and print the sum .
sum=0
num=int(input("please enter a number:"))
for i in range(1,(num+1)):
sum=sum+i
print("sum of numbers 1to",num,"is",sum)

Output:

please enter a number:8


sum of numbers 1to 8 is 1
sum of numbers 1to 8 is 3
sum of numbers 1to 8 is 6
sum of numbers 1to 8 is 10
sum of numbers 1to 8 is 15
sum of numbers 1to 8 is 21
sum of numbers 1to 8 is 28
sum of numbers 1to 8 is 36
15)Program to calculate and print the sums of even an odd
integers of the first n natural numbers.
n=int(input("u to which natural number ?"))
ctr=1
sum_even=0
sum_odd=0
while ctr <=n:
if ctr%2==0:
sum_even+=ctr
else:
sum_odd+=ctr
ctr+=1
print("the sum of even integers is",sum_even)
print("the sum of odd integers",sum_odd)

Output:

to which natural number ?25


the sum of even integers is 156
the sum of odd integers 169
16) Program to input two numbers(first number 1n been less
than second number n2).
n1=int(input("enter the starting number:"))
n2=int(input("enter the ending number:"))
num=n1
count=0
while num<=n2:
if (num%2)>0:
count+=1
num+=1
print("no.of odd numbers in the given range is:",count)

Output:

enter the starting number:13


enter the ending number:27
no.of odd numbers in the given range is: 8
17)program to create the original photo to blur photo
import cv2
img = cv2.imread('dog.jpg')
cv2.imshow('Original Image',img
Image',img)
cv2.imshow('cv2.blur output', cv2.blur(img, (3,3)))
cv2.waitKey(0)
cv2.destroyAllWindows()

Output:
18)program to create the original photo to sketch photo

import cv2
img = cv2.imread('dog.jpg')
edges = cv2.Canny(img,200,300,True)
cv2.imshow("Edge Detected Image", edges)
cv2.imshow("Original Image", img)
cv2.waitKey(0) # waits until a key is pressed
cv2.destroyAllWindows() # destroys the window showing image

Output:
19)program to create original photo to bilateral photo
import cv2

img = cv2.imread('dog.jpg')

cv2.imshow('Original Image',img)

cv2.imshow('bilateral Image', cv2.bilateralFilter(img,9,75,75))


cv2.waitKey(0)

cv2.destroyAllWindows()

output:

You might also like