0% found this document useful (0 votes)
9 views7 pages

Ai Record

Uploaded by

Divyesh Anand
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)
9 views7 pages

Ai Record

Uploaded by

Divyesh Anand
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/ 7

SUBJECT : ARTIFICIAL INTELLIGENCE

SUBJECT CODE : 417

ACTIVITY : 1
#1 To print welcome note
print('AMRITA VIDYALAYAM, KANYAKUMARI')
print('Welcome to Python Programming')
print('Welcome to the world of Artificial Intelligence')

Output:
AMRITA VIDYALAYAM, KANYAKUMARI
Welcome to Python Programming
Welcome to the world of Artificial Intelligence

ACTIVITY : 2
#2 To calculate simple and compound interest
p=10000
n=10
r=5
si=(p*n*r)/100
ci=p*(1+(r/100))**n‒p
print('Simple Interest : ', si)
print('Compound Interest : ', ci)

Output:
Simple Interest : 5000.0
Compound Interest : 6288.94

ACTIVITY : 3
#3 To calculate area and perimeter of rectangle
l=int(input('Enter length of the rectangle : '))
b=int(input('Enter breadth of the rectangle : '))
area=l*b
peri=2*(l+b)
print('Area of rectangle : ', area)
print('Perimeter of rectangle : ', peri)

Output:
Enter length of the rectangle : 50
Enter breadth of the rectangle : 40
Area of rectangle : 2000
Perimeter of rectangle : 180
Page No. 1
ACTIVITY : 4
#4 To calculate area of triangle based on 3 sides
import math
print('Enter three sides of the triangle ')
a=float(input())
b=float(input())
c=float(input())
s=(a+b+c)/2
area=math.sqrt(s*(s‒a)*(s‒b)*(s‒c))
print('Area of triangle : ', area)

Output:
Enter three sides of the triangle
4
5
3
Area of triangle : 6.0

ACTIVITY : 5
#5 To check whether the number is odd or even
n=int(input('Enter a number : '))
if n%2==0:
print(n, ' is an even number')
else:
print(n, ' is an odd number')

Output:
Enter a number : 88
88 is an even number

Enter a number : 33
33 is an odd number

ACTIVITY : 6
#6 To check whether the number is positive or negative
n=int(input('Enter a number : '))
if n>0:
result='positive'
elif n<0:
result='negative'
else:
result='neutral'
print(n, 'is', result)
Page No. 2
Output:
Enter a number : 55
55 is positive

Enter a number : ‒55


‒55 is negative

Enter a number : 0
0 is neutral

ACTIVITY : 7
#7 To find the biggest of 3 numbers
print('Enter three numbers')
a=float(input())
b=float(input())
c=float(input())
if a>b and a>c:
big=a
elif b>a and b>c:
big=b
else:
big=c
print('Biggest Number : ', big)

Output:
Enter three numbers
70
60
365
Biggest Number : 365.0

ACTIVITY : 8
#8 To print first n natural numbers & its square
n=int(input('Enter the value of n : '))
print('n', 'square', sep='\t')
for i in range(1, n+1):
print(i, i*i, sep='\t')

Page No. 3
Output:
Enter the value of n : 10
n square
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100

ACTIVITY : 9
#9 To print the multiplication table
n=int(input('Enter the value of n : '))
for i in range(1, 11):
print(i, 'x', n, '=', i*n)

Output:
Enter the value of n : 5
1x5=5
2 x 5 = 10
3 x 5 = 15
4 x 5 = 20
5 x 5 = 25
6 x 5 = 30
7 x 5 = 35
8 x 5 = 40
9 x 5 = 45
10 x 5 = 50

ACTIVITY : 10
#10 To print the sum of first n natural numbers
n=int(input('Enter the value of n : '))
sum=0
for i in range(1, n+1):
sum+=i
print('sum of first n natural numbers : ', sum)

Page No. 4
Output:
Enter the value of n : 5
sum of first n natural numbers : 15

ACTIVITY : 11
#11 To assign grade based on the percentage
percent=float(input('Enter Percentage : '))
if percent>=80:
grade='A'
elif percent>=60 and percent<80:
grade='B'
elif percent>=50 and percent<60:
grade='C'
elif percent>=33 and percent<50:
grade='D'
else:
grade='E'
print('Grade : ', grade)

Output:
Enter Percentage : 88
Grade : A
Enter Percentage : 77
Grade : B
Enter Percentage : 55
Grade : C
Enter Percentage : 44
Grade : D
Enter Percentage : 30
Grade : E

ACTIVITY : 12
#12 To create a list and display its elements
happy=[]
print('Enter the synonyms of word happy ')
for i in range(5):
print('Enter Data', i+1)
data=input()
happy.append(data)
print('List=', happy)

Page No. 5
Output:
Enter the synonyms of word happy
Enter Data 1
Joyful
Enter Data 2
Blissful
Enter Data 3
Pleased
Enter Data 4
Delighted
Enter Data 5
Ecstatic
List= ['Joyful', 'Blissful', 'Pleased', 'Delighted', 'Ecstatic']

ACTIVITY : 13
#13 To use list operators
a=[10, 20,30]
b=[11, 22]
c=a+b
d=b*3
print('List A : ', a)
print('List B : ', b)
print('List C : ', c)
print('List D : ', d)

Output:
List A : [10, 20, 30]
List B : [11, 22]
List C : [10, 20, 30, 11, 22]
List D : [11, 22, 11, 22, 11, 22]

ACTIVITY : 14
#14 To calculate mean, median, mode
import numpy
import statistics
m=[30, 20, 50, 60, 20]
n=numpy.array(m)
print('Array=', n)
print('Mean=', statistics.mean(n))
print('Median=', statistics.median(n))
print('Mode=', statistics.mode(n))

Page No. 6
Output:
Array=[30, 20, 50, 60, 20]
Mean=36
Median=30
Mode=20

ACTIVITY : 15
#15 To display a bar chart
import matplotlib.pyplot as plt
sub=['English', 'LangII', 'Maths', 'Science', 'Social']
marks=[80, 70, 100, 70, 90]
plt.bar(sub, marks)
plt.title('Score Chart')
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.show()

Output:

Score Chart
100
80
60
Marks

40
20
0
English LangII Maths Science Social
Subjects

Page No. 7

You might also like