0% found this document useful (0 votes)
24 views15 pages

Class 10 AI Project File Examples

The document contains multiple Python programs demonstrating various functionalities such as list manipulation, statistical calculations, data visualization with matplotlib, CSV file handling, image processing with OpenCV, string manipulation, and basic mathematical operations. Each program is accompanied by its output, showcasing the results of the executed code. The programs cover a range of topics from calculating mean, median, and mode to plotting graphs and determining the type of triangle based on user input.

Uploaded by

hellot5785
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)
24 views15 pages

Class 10 AI Project File Examples

The document contains multiple Python programs demonstrating various functionalities such as list manipulation, statistical calculations, data visualization with matplotlib, CSV file handling, image processing with OpenCV, string manipulation, and basic mathematical operations. Each program is accompanied by its output, showcasing the results of the executed code. The programs cover a range of topics from calculating mean, median, and mode to plotting graphs and determining the type of triangle based on user input.

Uploaded by

hellot5785
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

Program 1

S1=[32,45,40]
S2=[35,30,42,38]
print("*** List S1 ***")
print(S1,len(S1))
print("*** List S2 ***")
print(S2,len(S2))
All=S1+S2
print("*** List All ***")
print(All,len(All))

OUTPUT:
*** List S1 ***
[32, 45, 40] 3
*** List S2 ***
[35, 30, 42, 38] 4
*** List All ***
[32, 45, 40, 35, 30, 42, 38] 7
Program 2
import statistics
d = [95,90,49,71,90,100,55]
m1 = [Link](d)
m2 = [Link](d)
m3 = [Link](d)
print("The mean is: ", m1)
print("The median is: ", m2)
print("The mode is: ", m3)

OUTPUT:

The mean is: 78.57142857142857


The median is: 90
The mode is: 90
Program 3
import [Link] as plt
import numpy as np
# Define X and Y variable data
x = [Link]([2,3,9,10])
y = x*2
[Link](x,y)
[Link]("X-axis") #add X-axis label
[Link]("Y-axis") #add y-label
[Link]("Line Chart") #add title
[Link]()

OUTPUT:
Program 4
import [Link] as plt
import numpy as np
x = [Link]([2, 9, 8, 5, 6])
y = [Link]([5, 10, 3, 7, 18])
[Link]("X-axis")
[Link]("Y-axis")
[Link]("Scatter Chart")
[Link](x, y)
[Link]()
OUTPUT:
Program 5
import csv
with open('[Link]', 'a', newline="") as CF:
CW = [Link](CF)
[Link](['Adm No', 'Name', 'Percentage'])
[Link]([111, 'Aman Verma', 87])
[Link]([152, 'Vartika Sen', 89])
[Link]([123, 'Shipra Virmani', 80])
[Link]([214, 'Jyoti Batra', 78])
[Link]([167, 'Ayana Joshi', 92])
[Link]([142, 'Ekta Mishra', 76])
[Link]([216, 'Mansi Kapoor', 72])
[Link]([147, 'Shivani Monga', 81])
[Link]([181, 'Poonam Gupta', 67])
with open('[Link]', 'r') as cF:
CV = [Link](cF, delimiter=',')
for c in CV:
print(c)
OUTPUT:

['Adm No', 'Name', 'Percentage']


['111', 'Aman Verma', '87']
['152', 'Vartika Sen', '89']
['123', 'Shipra Virmani', '80']
['214', 'Jyoti Batra', '78']
['167', 'Ayana Joshi', '92']
['142', 'Ekta Mishra', '76']
['216', 'Mansi Kapoor', '72']
['147', 'Shivani Monga', '81']
['181', 'Poonam Gupta', '67']
Program 6
import csv
with open("[Link]", "w") as cF:
cW = [Link](cF)
[Link](['Bookno', 'Bookname', 'Price'])
[Link](['B101', 'The Kite Runner', 500])
[Link](['B102', 'Julius Ceasar', 250])
[Link](['B103', 'Fault in our Stars', 650])
[Link](['B111', 'Freedom Fighters', 1100])

try:
with open("[Link]", "r") as CF:
cR = [Link](CF)
for L in cR:
print(L)
except FileNotFoundError:
print("File Not Found")
OUTPUT:
['Adm No', 'Name', 'Percentage']
['111', 'Aman Verma', '87']
['152', 'Vartika Sen', '89']
['123', 'Shipra Virmani', '80']
['214', 'Jyoti Batra', '78']
['167', 'Ayana Joshi', '92']
['142', 'Ekta Mishra', '76']
['216', 'Mansi Kapoor', '72']
['147', 'Shivani Monga', '81']
['181', 'Poonam Gupta', '67']
['Adm No', 'Name', 'Percentage']
['111', 'Aman Verma', '87']
['152', 'Vartika Sen', '89']
['123', 'Shipra Virmani', '80']
['214', 'Jyoti Batra', '78']
['167', 'Ayana Joshi', '92']
['142', 'Ekta Mishra', '76']
['216', 'Mansi Kapoor', '72']
['147', 'Shivani Monga', '81']
['181', 'Poonam Gupta', '67']
Program 7
import cv2
from matplotlib import pyplot as plt
import numpy as npx
img = [Link]('D:/[Link]')
[Link](img)
[Link]('My Favourite City')
[Link]('off')
[Link]()
OUTPUT:
Program 8
import cv2
from matplotlib import pyplot as plt
import numpy as np
image = [Link]('F:/[Link]')
height, width, channels = [Link]
print("Image shape:")
print("Height:", height)
print("Width:", width)
print("Number of channels:", channels)
OUTPUT:
Image shape:

Height: 499
Width: 499
Number of channels: 3
Program 9
str = input("Please enter a string as you wish: ")
vowels = 0
consonants = 0
for i in str:
if i in 'aeiouAEIOU':
vowels += 1
else:
consonants += 1

print("The number of vowels:", vowels)


print("The number of consonants:", consonants)

OUTPUT:

Please enter a string as you wish: Balvantray Mehta Vidya


Bhawan (ASMA)
The number of vowels: 11
The number of consonants: 25
Program 10
def reverse_string(str):
str1 = ""
for i in str:
str1 = i + str1
return str1

str = "ArtificialIntelligence"
print("The original string is: ", str)
print("The reverse string is:", reverse_string(str))

OUTPUT:

The original string is: ArtificialIntelligence


The reverse string is: ecnegilletnIlaicifitrA
Program 11
n = int(input("Enter a number: "))
factorial = 1
if n < 0:
print("Factorial does not exist for negative numbers")
elif n== 0:
print("The factorial of 0 is 1")
else:
for i in range(1,n + 1):
factorial = factorial*i
print("The factorial of",n," is",factorial)

OUTPUT:

Enter a number: 7
The factorial of 7 is 5040
Program 12
print("Input the sides of a triangle: ")
A = int(input("A: "))
B = int(input("B: "))
C = int(input("C: "))
if A == B == C:
print("Equilateral triangle")
elif A==B or B==C or A==C:
print("isosceles triangl;e")
else:
print("Scalene triangle")
OUTPUT:
Input the sides of a triangle:
A: 2
B: 2
C: 4
isosceles triangle

You might also like