AI Project
AI Project
AI Project
CLASS IX
ARTIFICIAL INTELLIGENCE
PRACTICAL FILE
NAME:
SRIJAN
GHOSH
SECTION:
9th A
PROGRAM 1
Program :
# Python3 program to add two numbers
num1 = 15
num2 = 12
# printing values
print("Sum of", num1, "and", num2 , "is", sum)
Output:
PROGRAM 2
Program :
# Python program to find the
# maximum of two numbers
if a >= b:
return a
else:
return b
# Driver code
a=2
b=4
print(maximum(a, b))
Output:
PROGRAM 3
Program :
# Python 3 program to find
# factorial of given number
def factorial(n):
# Driver Code
num = 5
print("Factorial of",num,"is",factorial(num))
Output:
PROGRAM 4
Program :
# Python3 program to find simple interest
# for given principal amount, time and
# rate of interest.
def simple_interest(p,t,r):
print('The principal is', p)
print('The time period is', t)
print('The rate of interest is',r)
si = (p * t * r)/100
# Driver code
simple_interest(8, 6, 8)
Output:
PROGRAM 5
Program :
# Python3 program to find compound
# interest for given values.
# Driver Code
compound_interest(10000, 10.25, 5)
Output:
PROGRAM 6
Program :
# Python program to determine whether
# the number is Armstrong number or not
if y == 0:
return 1
if y % 2 == 0:
return power(x, y // 2) * power(x, y // 2)
return n
n = order(x)
temp = x
sum1 = 0
# If condition satisfies
return (sum1 == x)
# Driver code
x = 153
print(isArmstrong(x))
x = 1253
print(isArmstrong(x))
Output:
PROGRAM 7
Program :
# Python3 program to swap first
# and last element of a list
# Swap function
def swapList(newList):
size = len(newList)
# Swapping
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList
# Driver code
newList = [12, 35, 9, 56, 24]
print(swapList(newList))
Output:
PROGRAM 8
Program :
# Solve the quadratic equation ax**2 + bx + c = 0
a=1
b=5
c=6
PROGRAM 9
Program :
# Square root calculation
import math
math.sqrt(4)
Output:
PROGRAM 10
Program :
num1 = 5
num2 = 5.42
num3 = 8+2j
Output:
PROGRAM 11
Program :
num1 = int(2.3)
print(num1) # prints 2
num2 = int(-2.8)
print(num2) # prints -2
num3 = float(5)
num4 = complex('3+5j')
Output:
PROGRAM 12
Program :
import random
print(random.randrange(10, 20))
print(random.choice(list1))
# Shuffle list1
random.shuffle(list1)
print(list1)
print(random.random())
Output:
PROGRAM 13
Program :
import math
print(math.pi)
print(math.cos(math.pi))
print(math.exp(10))
print(math.log10(1000))
print(math.sinh(1))
print(math.factorial(6))
Output:
PROGRAM 14
Program :
import random
random.seed(2)
print(random.random())
print(random.random())
print(random.random())
Output:
PROGRAM 14
Program :
number = -20
absolute_number = abs(number)
print(absolute_number)
# Output: 20
Output: