ARTIFICIAL INTELLIGENCE
PRACTICAL FILE
SUBMITTED TO: SUBMITTED BY:
Keshav Aggarwal
PGT AI
1
INDEX
SNO PRACTICAL PG NO REMARKS
1 To create system maps using loopy. 3
2 To play Rock, Paper, Scissors Game and Aiknator (Statistical 4
Data) and paste it’s screenshots.
3 To play semantics(Arcade and block based) on NLP and paste 5
their screenshots.
4 To apply filters, quick draw game and AI for Ocean based on CV 6-7
and paste their screenshots.
5 Write a python program that takes input of 3 numbers and print the 8
largest of 3 numbers using if statement in python.
6 Write a python program that takes input of a character and check 9
whether it is in uppercase, lowercase character or a digit or any
other special character.
7 Write a python program to print the sum of even or odd numbers 10
of first n natural numbers in python.
8 Write a python program to store only integers in a new list by 11
copying from the given list.
9 Write a python program to search a specific value and display its 12
number of occurrences in a list.
10 Write a python program to input billing amount and gender. If the 13
billing amount is more than 10000 and gender is female, then
discount is 15% otherwise, discount is 10%. Calculate the billing
amount accordingly.
11 Write a python program to make a calculator. 14
12 Write a python program to add a list to existing list and replicate a 15
particular list.
13 Write a python program to display the list in reverse order 16
14 Write the python programs to showcase simple mathematical 17
operations .
15 Write the python programs to show usage of input function . 18-19
16 Write the python programs to show usage of list function . 20-21
17 Write the python programs to show usage of for and while loops. 22-23
2
PRACTICAL NO 1
To create system maps using loopy.
Theme: Road Safety for Pedestrians
3
PRACTICAL NO 2
To play Rock, Paper, Scissors Game and Aiknator (Statistical Data) and paste it’s screenshots.
4
PRACTICAL 3
To play semantics(Arcade and block based) on NLP and paste their screenshots.
5
Practical No 4
To apply filters, quick draw game and AI for Ocean based on CV and paste their screenshots.
6
7
PRACTICAL 5
Write a python program that takes input of 3 numbers and print the largest of 3 numbers using if
statement in python.
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
if (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)
8
PRACTICAL 6
WAP to input a character and check whether it is in uppercase, lowercase character or a digit or any
other special character.
ch = input("Enter a character: ")
if ch >= '0' and ch <= '9':
print("Digit")
elif ch.isupper ():
print("Uppercase character")
elif ch.islower ():
print("Lowercase character")
else:
print("Special character")
9
PRACTICAL 7
Write a python program to print the sum of even or odd numbers of first n natural numbers in
python.
maximum = int(input(" Please Enter the Maximum Value : "))
even_total = 0
odd_total = 0
for number in range(1, maximum + 1):
if(number % 2 == 0):
even_total = even_total + number
else:
odd_total = odd_total + number
print("The Sum of Even Numbers:”, even_total))
print("The Sum of Odd Numbers:”, odd_total))
10
PRACTICAL 8
Write a python program to store only integers in a new list by copying from the given list.
Mix=[12, “abc”, 45.6, True, 34, 45]
Mix2 = []
for i in Mix:
if type(i)== int:
Mix2.append(i)
print(Mix2)
11
PRACTICAL 9
Write a python program to search a specific value and display its number of occurrences in a list.
A=[10,23,45,10,12,34,10,56]
S=int(input(“enter value you want to search”))
Count=0
for i in A:
if i==S:
count+=1
print(S,” occurs “, count,” times”)
12
PRACTICAL 10
Write a python program to input billing amount and gender. If the billing amount is more than 10000
and gender is female, then discount is 15% otherwise, discount is 10%. Calculate the billing amount
accordingly.
bill=float(input(“Enter the billing amount”))
gender=input(“Enter the gender”)
if(bill>10000 and gender==”female”):
bill=bill-(0.15*bill)
print(“your bill is: “, bill)
else:
bill=bill-(0.10*bill)
print(“your bill is: “, bill)
13
PRACTICAL 11
Write a python program to make a calculator.
N1= int(input(“Enter first number:”))
N2=int(input(“Enter second number”)
print(“Press 1 to add”)
print(“Press 2 to subtract”)
print(“Press 3 to multiply”)
print(“Press 4 to divide”)
op=int(input(“Enter your choice”)
if op==1:
result=N1+N2
print(“The result of addition is: “, result)
elif op==2:
result=N1-N2
print(“The result of subtraction is: “, result)
elif op==3:
result=N1*N2
print(“The result of multiplication is: “, result)
elif op==4:
result=N1/N2
print(“The result of division is: “, result)
else:
print(“Invalid choice”)
14
PRACTICAL 12
Write a python program to add a list to existing list and replicate a particular list.
#adding two list
list1=[1,2,3]
list2=[4,5,6]
list3=list1+list2
print(list3)
Output:
[1,2,3,4,5,6]
#Replicate the list
A = [1,2,3]
B = A*3
print(B)
Output:
[1,2,3,1,2,3,1,2,3]
15
PRACTICAL 13
To display the list in reverse order
list1 = ['E','D','U','C','A','T','I','O','N']
print(list1[::-1])
OUTPUT:
['N', 'O', 'I', 'T', 'A', 'C', 'U', 'D', 'E']
16
PRACTICAL 14
Write the python programs to showcase simple mathematical operations .
# Square of 7
print(“Square of 7 is:”, 7 * 7)
# Sum of 15 and 20
print(“Sum is:”, 15 + 20)
# Convert km to meters
km = 5
print(“Length in meters:”, km * 1000)
# Table of 5 up to five terms
for i in range(1, 6):
print(f”5 x {i} = {5 * i}”)
# Simple Interest
P = 2000
R = 10
T = 4.5
si = (P *R * T) / 100
print(“Simple Interest is:”, si)
17
PRACTICAL 15
Write the python programs to show usage of input function .
# Area and Perimeter of Rectangle
l = float(input(“Enter length: “))
b = float(input(“Enter breadth: “))
print(“Area:”, l * b)
print(“Perimeter:”, 2 * (l + b))
# Area of Triangle
base = float(input(“Enter base: “))
height = float(input(“Enter height: “))
print(“Area of triangle:”, 0.5 * base * height)
# Average of 3 Subjects
M1 = float(input(“Enter marks of Subject 1: “))
M2 = float(input(“Enter marks of Subject 2: “))
M3 = float(input(“Enter marks of Subject 3: “))
print(“Average:”, (M1 + M2 + M3) / 3)
# Discounted Amount
price = float(input(“Enter original price: “))
Discount = float(input(“Enter discount percentage: “))
18
Discount_amount = (Discount / 100) * price
final_price = price – Discount_amount
print(“Discounted price:”, final_price)
# Surface Area and Volume of Cuboid
l = float(input(“Enter length: “))
b = float(input(“Enter breadth: “))
h = float(input(“Enter height: “))
surface_area = 2 * (l*b + b*h + h*l)
volume = l * b * h
print(“Surface Area:”, surface_area)
print(“Volume:”, volume)
19
PRACTICAL 16
Write the python programs to show usage of list function .
# Science Quiz List Operations
Children = [“Arjun”, “Sonakshi”, “Vikram”, “Sandhya”, “Sonal”, “Isha”, “Kartik”]
print(Children)
Children.remove(“Vikram”)
Children.append(“Jay”)
Children.pop(1) # second position
print(children)
# List Operations on num
num = [23, 12, 5, 9, 65, 44]
print(“Length:”, len(num))
print(“2nd to 4th (positive index):”, num[1:4])
print(“3rd to 5th (negative index):”, num[-4:-1])
20
# Add 1 to first 10 even numbers
even = list(range(2, 21, 2))
new_list = [x + 1 for x in even]
print(“Modified list:”, new_list)
# Add and sort list
List_1 = [10, 20, 30, 40]
List_1.extend([14, 15, 12])
List_1.sort()
print(“Sorted List:”, List_1)
21
PRACTICAL 17
Write the python programs to show usage of for and while loops.
# Voting
age = int(input(“Enter age: “))
if age >= 18:
print(“You can vote”)
else:
print(“You cannot vote”)
# Grade
marks = int(input(“Enter marks: “))
if marks >= 90:
print(“Grade: A”)
elif marks >= 75:
print(“Grade: B”)
elif marks >= 50:
print(“Grade: C”)
else:
print(“Grade: D”)
# Number check
22
n = int(input(“Enter a number: “))
if n > 0:
print(“Positive number”)
elif n < 0:
print(“Negative number”)
else:
print(“Zero”)
# Print first 10 natural numbers
for i in range(1, 11):
print(I, end=” “)
# Print first 10 even numbers
for i in range(2, 21, 2):
print(I, end=” “)
# Print odd numbers from 1 to n
n= int(input(“Enter n: “))
for i in range(1, n+1, 2):
print(I, end=” “)
# Sum of first 10 natural numbers
s = sum(range(1, 11))
print(“Sum:”, s)
# Sum of all numbers in list
lst = [3, 5, 8, 2, 1]
print(“Sum of list:”, sum(lst))
23