Ai Practical XTH Class
Ai Practical XTH Class
Ai Practical XTH Class
Practical File
Artificial Intelligence
Class X
Session: 2021-22
Submitted By: Submitted To:
Mrs. Ritika Keswani
Name: Ram Kushwah
Rollno: 31
Class: X
Section: D
Certificate
AI For ALL (AI Aware)
Certificate
AI For ALL (AI Appreciate)
INDEX
S.NO. PROGRAM
1. PRINT 5 LINES ABOUT YOURSELF USING PRINT()
FUNCTION
2. WRITE A PYTHON PROGRAM TO MULTIPLY TWO
NUMBERS
3. WRITE A PYTHON PROGRAM TO SWAP TWO VARIABLES
4. WRITE A PROGRAM TO FIND THE AREA OF A
RECTANGLE AND PERIMETER OF A RECTANGLE IN
PYTHON
5. WRITE A PYTHON PROGRAM TO FIND OR CALCULATE
SUM AND AVERAGE OF N NUMBERS
6. WRITE A PYTHON PROGRAM TO COMPUTE COMPOUND
INTEREST
7. WRITE A PYTHON PROGRAM TO FIND LARGEST/
MAXIMUM OF N NUMBERS
8. WRITE A PYTHON PROGRAM TO FIND CUBE OF A
NUMBER
9. WRITE A PYTHON PROGRAM TO CONVERT CELSIUS TO
FAHRENHEIT
10. WRITE A PYTHON PROGRAM TO DISPLAY CALENDAR
11. WRITE A PYTHON PROGRAM TO CHECK LEAP YEAR
12. WRITE A PYTHON PROGRAM TO CHECK VOTING
ELIGIBILITY
13. WRITE A PROGRAM TO CHECK WHETHER A NUMBER IS
EVEN OR NOT.
14. WRITE A PYTHON PROGRAM TO CHECK IF A NUMBER IS
POSITIVE, NEGATIVE OR ZERO.
15. WRITE A PYTHON PROGRAM TO DISPLAY THE
MULTIPLICATION TABLE
Example for Your Reference
WRITE A PYTHON PROGRAM TO PRINT "HELLO PYTHON"
FIVE TIMES.
CODE:
i=1
while i < 6:
print("Hello Python")
i += 1
OUTPUT:
Hello Python
Hello Python
Hello Python
Hello Python Hello Python
CODE:
OUTPUT
Introduction
1. My name is Ram Kushwah
2. I am studying in class 10th
3. I live in Gwalior
4. My hobbies are dancing and playing video games
5. The aim of my life is to become a ASTRONAUT
Output
OUTPUT
Enter value of x: 739
Enter value of y: 884
The value of x after swapping: 884
The value of y after swapping: 739
[Program finished]
4. WRITE A PROGRAM TO FIND THE AREA OF A
RECTANGLE AND PERIMETER OF A RECTANGLE IN
PYTHON
Code:
#wap TO FIND THE AREA OF A RECTANGLE
AND PERIMETER OF A RECTANGLE IN PYTHON
L=int(input('Enter the length of rectangle:'))
B=int(input('Enter the breadth of rectangle:'))
P=2*(L+B)
A=L*B
print('The perimeter of rectangle is, ',P,'cm')
print('The area of rectangle is, ',A,'cm^2')
Output
Enter the length of rectangle:9
Enter the breadth of rectangle:5
The perimeter of rectangle is, 28 cm
The area of rectangle is, 45 cm^2
[Program finished]
5. WRITE A PYTHON PROGRAM TO FIND OR CALCULATE
SUM AND AVERAGE OF N NUMBERS
Code:
n = input("Enter Number to calculate sum and
average")
n = int (n)
totalNo = n
sum=0
while (n >= 0):
sum += n
n-=1
average = sum / totalNo
print ("sum of ", totalNo ,"using while loop ",
sum)
print ("average of", totalNo ,"using while loop
", average)
Output
Enter Number to calculate sum and average 10
sum of 10 using while loop 55
average of 10 using while loop 5.5
[Program finished]
6. WRITE A PYTHON PROGRAM TO COMPUTE COMPOUND
INTEREST
Code:
# WAP TO COMPUTE COMPOUND INTEREST
P=int(input('Enter the principle amount : '))
R=int(input('Enter the rate of interest : '))
n=int(input('Enter the time span : '))
A= P*(1+R/100)**n
CI= A-P
print('The Compound Interest is ',CI,'Rs')
Output:
Enter the principle amount : 90000
Enter the rate of interest : 10
Enter the time span : 2
The Compound Interest is
18900.000000000015 Rs
[Program finished]
Output:
How many numbers? 5
Enter number: 66
Enter number: 67
Enter number: 98
Enter number: 97
Enter number: 57
Largest element of the list is : 98
[Program finished]
Output:
[Program finished]
Code:
#wap to convert celsius to fahrenheit
C=int(input('Enter the temperature in celsius:
'))
F=9*C/5+32
print('The temperature in fahrenheit is',F)
Output:
[Program finished]
10. WRITE A PYTHON PROGRAM TO DISPLAY CALENDAR
Code:
import calendar
yy = int(input("Enter year: "))
mm = int(input("Enter month: "))
# display the calendar
print(calendar.month(yy, mm))
Output:
Enter year: 2022
Enter month: 01
January 2022
Mo Tu We Th Fr Sa Su
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[Program finished]
11. WRITE A PYTHON PROGRAM TO CHECK LEAP YEAR
Code:
def CheckLeap(Year):
# Checking if the given year is leap year
if((Year % 400 == 0) or
(Year % 100 != 0) and
(Year % 4 == 0)):
print("Given Year is a leap Year");
# Else it is not a leap year
else:
print ("Given Year is not a leap Year")
# Taking an input year from user
Year = int(input("Enter the number: "))
# Printing result
CheckLeap(Year)
Output:
Enter the number: 2000
Given Year is a leap Year
[Program finished]
12. WRITE A PYTHON PROGRAM TO CHECK VOTING
ELIGIBILITY
Code:
#WAP TO CHECK VOTING ELIGIBILITY
Age=int(input('Enter your age :'))
if Age>=18:
print('You are eligible to vote')
else:
print('You are not eligible to vote')
Output:
[Program finished]
Output:
[Program finished]
Output:
Enter the number :-6362782
The number is negative
[Program finished]