Artificial Intelligence
Artificial Intelligence
PRACTICAL FILE
Name: Chhavi
Roll no: 06
This is to certify that Chhavi Anand of class _IXF_, Roll No _6_ has completed AI Report File under my
supervision and guidance as per the latest curriculum of Central Board of Secondary Education (2023-2024).
Teacher In-charge
Date: 24.09.23
ACKNOWLEDGEMENT
In the accomplishment of this practical file successfully, many people have best owned upon me their blessings
and the heart pledged support, this time I am utilizing to thank all the people who have been concerned with this
practical file. Primarily I would thank God for being able to complete this project with success. Then I would
like to thank my Principal Mr. Gaurav Bedi and Artificial Intelligence teacher Ms. Shivani Singhal whose
valuable guidance has been the ones that helped me prepare this file and make it a success. Their suggestions
and instructions have served as the major contributor towards the completion of the file. Then I would like to
thank my parents and friends who have helped me with their valuable suggestions and guidance has been very
helpful in various phases. Last but not the least I would like to thank my classmates who have helped me a lot.
Roll no: 06
INDEX
S.NO TOPIC
1 Write a python program to input dimensions of a circle from the user and calculate
the area.
2 Write a program to print the multiplication table of the number given by the user.
3 Write a Python program to convert days into years, weeks and months.
6 Write a program to enter 3 angles and find whether it's a valid triangle or not.
8 Write a program to input electricity unit charges and calculate total electricity bill
according to the given condition:
● For first 50 units Rs. 0.50/unit
● For next 100 units Rs. 0.75/unit
● For next 100 units Rs. 1.20/unit
● For unit above 250 Rs. 1.50/unit
12 Write a program to calculate profit or the loss based on the Cost price and
Selling price entered by the user.
13 Write a program to check whether the triangle is equilateral, scalene or isosceles.
14 Write a program to print a multiplication table of the number entered by the user
using the while loop
15 Write a program to count total digits in a number.
19 Write a program find the sum of the series upto n terms using for loop
20 Write a program to enter the numbers till the user wants and print the sum of
all the numbers at the end of the program using for loop
Program 1: To input dimensions of a circle from the user and calculate the area.
Source Code :-
Output :-
Program 2: Write a program to print the multiplication table of the number given by the user.
Output :-
Program 3: Write a Python program to convert days into years, weeks and months.
Source Code :-
year = int(num/365)
week = int(num/7)
months = int(num/30)
Output :-
Program 4: Write a program to print the value of x,
where x = 3 + 32 +33 +34
Source Code :-
x= 3+3**2+3**3+3**4
print(x)
Output :-
Program 5: Write a python program to find whether a person is eligible to be categorised as a senior
citizen or not, depending on the input age.
Source Code :-
Output :-
Program 6: Write a program to enter 3 angles and find whether it's a valid triangle or not
Source Code :-
Output :-
Program 7: Write a program to find whether a number is divisible by 5 and 11.
Source Code :-
Output :-
Program 8: Write a program to input electricity unit charges and calculate total electricity bill according to
the given condition:
● For first 50 units Rs. 0.50/unit
● For next 100 units Rs. 0.75/unit
● For next 100 units Rs. 1.20/unit
● For unit above 250 Rs. 1.50/unit
Source Code :-
Output :-
Program 9: Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and
Computer. Calculate percentage and grade according to following:
● Percentage >= 90% : Grade A
● Percentage >= 80% : Grade B
● Percentage >= 70% : Grade C
● Percentage >= 60% : Grade D
● Percentage >= 40% : Grade E
● Percentage < 40% : Grade F
Source Code :-
physics = int(input("Enter Physics marks"))
chemistry = int(input("Enter Chemistry marks")
biology = int(input("Enter Biology marks"))
mathematics = int(input("Enter Mathematics marks"))
computer = int(input("Enter Computer marks"))
total_marks = physics + chemistry + biology + mathematics +
computer percentage = (total_marks / 500) * 100
if percentage >= 90:
grade = "Grade A"
elif percentage >= 80:
grade = "Grade B"
elif percentage >= 70:
grade = "Grade C"
elif percentage >= 60:
grade = "Grade D"
elif percentage >= 40:
grade = "Grade E"
else:
grade = "Grade F"
print("Percentage:", percentage,
"%") print("Grade:", grade)
Output :-
Program 10: Write a program to find the season based on the month entered. [March - June = Summer,
July-October = Rainy, November - February = Winter]
Source Code :-
if month in summer_months:
season = "Summer"
elif month in rainy_months:
season = "Rainy"
elif month in winter_months:
season = "Winter"
else:
season = "Invalid month"
Output :-
Program 11: Write a program to find whether a year is a leap year or not.
Source Code :-
Output :-
Program 12: Write a program to calculate profit or the loss based on the Cost price and Selling price
entered by the user.
Source Code :-
cp=int(input("Enter the cost Price of an Item :"))
sp=int(input("Enter the Selling Price of an Item :"))
if (sp > cp):
print("Profit :",sp -
cp) elif( cp > sp):
print("Loss :",cp - sp)
else:
print("No Profit No Loss")
Output :-
Program 13: Write a program to check whether the triangle is equilateral, scalene or isosceles.
Source Code :-
a = float(input("Enter length of side 1: "))
b = float(input("Enter length of side 2: "))
c = float(input("Enter length of side 3: "))
if a == b == c:
print("Triangle is Equilateral")
elif a == b or b == c or a == c:
print("Triangle is Isosceles")
else:
print("Triangle is Scalene")
Output :-
Program 14: Write a program to print a multiplication table of the number entered by the user using the
while loop
Source Code :-
n = int(input("Enter any Number :"));
i=1
while i <= 10:
value = n * i
print(value)
i=i+1
Output :-
Program 15: Write a program to count total digits in a number.
Source Code :-
num = int(input("Enter any Number :"));
count = 0
while num != 0:
num //= 10
count += 1
Output :-
Program 16: Write a program to print the following pattern
*
**
***
****
*****
Source Code :-
rows = 5
print("Pattern:")
for i in range(1, rows +
1): print("*" * i)
Output :-
Program 17: Write a program to print list in reverse order using a loop.
Source Code :-
my_list = [1, 2, 3, 4, 5]
Output :-
Program 18: Write a program reverse a given integer number using for loop
Source Code :-
number = int(input("Enter an integer: "))
number_str = str(number)
reversed_num = ""
for digit in
reversed(number_str):
reversed_num += digit
reversed_number = int(reversed_num)
print(f"Reversed number:
{reversed_number}")
Output :-
Program 19: Write a program find the sum of the series upto n terms using for loop
Source Code :-
n = int(input("Enter the number of terms: "))
sum = 0
for i in range(1, n +
1): sum = sum+i
Output :-
Program 20: Write a program to enter the numbers till the user wants and print the sum of all the numbers
at the end of the program using for loop
Source Code :-
sum_of_numbers = 0
while True:
num = float(input("Enter a number (enter 0 to stop): "))
if num == 0:
break
sum_of_numbers += num