Chettinad Vidyashram STD X - Record Programs - 2021 - 2022 Artificial Intelligence
Chettinad Vidyashram STD X - Record Programs - 2021 - 2022 Artificial Intelligence
1. Bonafide page – Write your name, class and section in block letters in the appropriate spaces
provided.
2. Fill the index neatly with the sno, title, and date given below. Page numbers according to the numbers
you start the new exercise. Write only the starting page of each exercise.
3. After the index, leave one page and start writing in the next page.
3. No scratches or overwriting.
4. Every exercise MUST start on a fresh page ONLY.
5. Write the date, title, question, coding in the ruled side with blue pen. Leave a line between the title,
question and coding.
6. In the unruled side cut and stick the output for each exercise. For this you have to take a printout of
the record programs.
7. Completed records will be checked and marked for internals.
INDEX:
PYTHON PROGRAMS
SNO DATE TITLE
1 7/6/21 TO CALCULATE THE BONUS OF AN EMPLOYEE
2 7/6/21 TO PRINT THE FIBONACCI SERIES USING while LOOP
3 14/6/21 TO PRINT THE FORMAT USING NESTED for LOOP
4 28/6/21 TO PERFORM OPERATIONS IN A LIST
5 28/6/21 TO SEARCH A STRING VALUE IN A TUPLE
6 5/7/21 TO CHANGE A VALUE IN A DICTIONARY USING THE KEY
7 5/7/21 TO PRINT THE ROOTS OF A QUADRATIC EQUATION
8 12/7/21 TO PRINT THE MULTIPLICATION TABLE
9 26/7/21 TO PRINT THE AREA AND CIRCUMFERENCE OF THE CIRCLE USING A
VARIABLE WITH THE CONSTANT VALUE
Accept name, grade and salary of an employee. Calculate the bonus as per the criteria given below and
print all the details.
Bonus calculation:
Salary Bonus
Grade A: <10000 18% of the salary
10000 – 20000 20% of the salary
>20000 22% of the salary
PROGRAM 1:
nam = input("ENTER EMPLOYEE NAME : ")
sal = float (input("ENTER THE SALARY : "))
grade = input("ENTER THE GRADE A/B : ")
if grade=='A':
if sal<10000:
b=sal*0.18
elif sal>=10000 and sal<=20000:
b=sal*0.20
else:
b=sal*0.22
elif grade=='B':
if sal<10000:
b=sal*0.24
elif sal>=10000 and sal<=20000:
b=sal*0.26
else:
b=sal*0.28
print("NAME : ", nam)
print("GRADE : ", grade)
print("SALARY : ", sal)
print("BONUS : ", b)
print("TOTAL SALARY :", sal+b)
OUTPUT 1:
Accept the number of terms and print the Fibonacci Series using while loop.
PROGRAM 2:
n=int(input("ENTER THE NUMBER OF TERMS : "))
i=3
a=0
b=1
print("FIBONACCI SERIES UPTO ", n, " TERMS : ")
print(a,end='\t')
print(b,end='\t')
while (i<=n):
c=a+b
print(c,end='\t')
a=b
b=c
i+=1
OUTPUT 2:
PROGRAM 3:
n=int(input("ENTER THE NUMBER OF ROWS : "))
c=1
print("FORMAT : ")
for i in range(1,n+1):
for j in range(1,i+1):
print(c,end=' ')
c+=1
print()
OUTPUT 3:
PROGRAM 4:
Assign a tuple with different elements. Accept a string value and print if it is present inside the tuple or
not.
PROGRAM 5:
t=(100, 'A', 'KAVIN', 105,'B','POOJA', 107, 'A', 'VINODH')
print("GIVEN TUPLE T= ", t)
c=0
nam=input("ENTER THE NAME FOR SEARCHING : ")
if nam in t:
print (nam, "IS PRESENT IN THE TUPLE")
else:
print (nam, "IS NOT PRESENT IN THE TUPLE")
OUTPUT 5:
===================
GIVEN TUPLE T= (100, 'A', 'KAVIN', 105, 'B', 'POOJA', 107, 'A', 'VINODH')
ENTER THE NAME FOR SEARCHING : POOJA
POOJA IS PRESENT IN THE TUPLE
GIVEN TUPLE T= (100, 'A', 'KAVIN', 105, 'B', 'POOJA', 107, 'A', 'VINODH')
ENTER THE NAME FOR SEARCHING : arun
arun IS NOT PRESENT IN THE TUPLE
Program 6. TO CHANGE A VALUE IN A DICTIONARY USING THE KEY
Assign a dictionary with the numbers from 1 – 7 as key and the names of the 7 wonders as the values.
Print the dictionary. Now change the value of key 2 from Hanging Gardens of Babylon to Redeemer
statue
PROGRAM 6:
OUTPUT 6:
PROGRAM 7:
import math
a=int(input("enter a:"))
b=int(input("enter b:"))
c=int(input("enter c:"))
d=(b*b)-(4*a*c)
if d==0:
print("Roots are real & equal\n")
print("r1 =", -b/(2*a))
elif d>0:
print("Roots are real & unequal\n")
print("r1=",(-b+math.sqrt(d))/(2*a))
print("r2=",(-b-math.sqrt(d))/(2*a))
else:
print("Roots are imaginary")
OUTPUT 7:
enter a:1
enter b:2
enter c:1
Roots are real & equal
r1 = -1.0
enter a:1
enter b:5
enter c:4
Roots are real & unequal
r1= -1.0
r2= -4.0
enter a:8
enter b:1
enter c:1
Roots are imaginary
Program 8. TO PRINT THE MULTIPLICATION TABLE
Accept the table and the limit and print the multiplication table.
PROGRAM 8:
OUTPUT 8:
Accept the radius and print area and circumference of the circle using a variable PI which has the
constant value 3.14.
PROGRAM 9:
const.py
PI=3.14
REC1.py
#INVOKING CONSTANT VALUE FROM ANOTHER FILE
import const #Importing the PI value from the file const.py
r=float(input("ENTER THE RADIUS : "))
print("VALUE OF PI = ", const.PI)
print("AREA OF THE CIRCLE = ", const.PI * r *r)
print("CIRCUMFERENCE OF THE CIRCLE=", round(2*const.PI*r),2)
OUTPUT 9:
ENTER THE RADIUS : 5
VALUE OF PI = 3.14
AREA OF THE CIRCLE = 78.5
CIRCUMFERENCE OF THE CIRCLE= 31. 2
PYTHON PROGRAMS FOR AI
Desktop Taskbar search box (near Start button) type cmd select command prompt type pip
install matplotlib press Enter key.
#Program Code 10
#PLOTTING GRAPHS USING matplotlib
from matplotlib import pyplot as plt
x=[5,2,9,4,7]
y=[10,5,8,4,2]
plt.plot(x,y,color="brown")
plt.ylabel("Y AXIS")
plt.xlabel("X AXIS")
plt.title("LINE GRAPH")
plt.show()
Output 10:
Program 11 : DATA ANALYSIS USING STATISTICS
Program to calculate and print mean, median and mode using the package statistics
# Program Code 11
# Printing mean, median and mode using statistics
# MEAN
import statistics
datasets=[5,9,7,4,2,6,8]
x=statistics.mean(datasets)
print("mean = ",round(x,2),"\n")
#MEDIAN
datasets=[4,-5,8,6,9,4,7,-2]
x=statistics.median(datasets)
print("median = ",round(x,2),"\n")
#MODE
set1 =[1, 2, 3, 3, 4, 4, 4, 5, 5, 6]
x=statistics.mode(set1)
print("mode = ",round(x,2),"\n")
Output 11:
mean = 5.86
median = 5.0
mode = 4
Program 12 : IMAGE HANDLING USING OPENCV
# Program Code 12
# Program using OpenCV to manipulate and display images
import cv2
im=cv2.imread("minion.jpg")
im=cv2.resize(im,(500,400))
cv2.imshow("INPUT IMAGE",im)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output 12: