You are on page 1of 13

ARTIFICIAL INTELLIGENCE (417)

Practical File
Class X (2023-2024)
Index

So.No. Topic Teacher


Signature
1 Python program to check given number is even or odd.
2 Python program to check given year is a leap year or not.
3 Python basic programming questions to calculate the square of a
number.
4 Python program to check given character is a vowel or
consonant.
5 Python program to print the Fibonacci series.
6 Python program to convert Fahrenheit into Celsius.
7 Python program to find smallest number among three.
8 Python program to print the following pattern.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
9 Python program to find:
a) Area of square
b) Area of circle
c) Area of rectangle
10 Python program to print Armstrong Number.
1. Python program to check given number is even or odd.

Program Code

num =int (input ("Enter a Number:"))


if num % 2 == 0:
print ("Given number is Even")
else:
print ("Given number is Odd”)

Output of the Program:


2. Python program to check given year is a leap year or not.

Program Code

year= int (input("Enter a year:"))


if (year % 400 == 0) and (year % 100 == 0):
print (year, "is a leap year")
elif (year % 4 ==0) and (year % 100 != 0):
print (year, "is a leap year")
else:
print (year, "is not a leap year")

Output of the Program:


3. Python basic programming questions to calculate the square of a
number.

Program Code

number = int (input ("Enter an integer number: "))


square = number * number
print ("Square of a", number, "is", square)

Output of the Program:


4. Python program to check given character is a vowel or consonant.

Program Code

character = input ("Enter a character: ")


vowels = ['a', 'e', 'i', 'o', u', 'A', 'E', 'I', 'O', U'l
if character in vowels:
print ("The character",character, "is a vowel!")
else:
print("The character",character," is a consonant!")

Output of the Program:


5. Python program to print the Fibonacci series.

Program Code
a=0
b=1
count=0
n = int(input("Enter the limit for the numbers to print:"))
while count < n:
print (a)
c=a+b
a=b
b= c
count=count+1

Output of the Program:


6. Python program to convert Fahrenheit into Celsius.

Program Code

temp = float (input ("Please enter temperature in fahrenheit:"))


celsius = (temp - 32) * 5 / 9
print( "Temperature in celsius: " , celsius)

Output of the Program:


7. Python program to find smallest number among three.

Program Code

a = int(input ("Enter 1st number:"))


b = int(input("Enter 2nd number:"))
c = int (input ("Enter 3rd number:"))
smallest = 0
if a< b and a<c:
smallest = a
if b< a and b<c:
smallest = b
if c < a and c< b:
smallest = c
print(smallest, "is the smallest of three numbers.”)
Output of the Program:
8. Python program to print the following pattern.
1
12
123
1234
12345

Program Code

rows = int(input ("Please enter how many rows you need: "))
for i in range(1, rows+1):
for j in range(1, i + 1):
print(j, end=’ ’)
print('')
Output of the Program:
9. Python program to find:

a) Area of square

Program Code

side = int(input("Enter the side:"))


Area = side*side
print("Area of the square=", Area)

Output of the Program:


b) Area of circle

Program Code

PI = 3.14
Radius = float (input ("Please enter the radius of the given
circle: "))
area_of_the_circle = PI * Radius * Radius
print (" The area of the given circle is: ", area of the circle)

Output of the Program:


c) Area of rectangle

Program Code

l = float (input ("Enter length:"))


b = float (input ("Enter breadth:"))
Area = 1 * b
print ("Area of rectangle = “, Area)

Output of the Program:


Q10) Python program to print Armstrong Number.

Program Code

num = int(input ("Enter a number: "))


sum =0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
# display the result
if num = = sum:
print (num, "is an Armstrong number")
else:
print (num, "is not an Armstrong number")

Output of the Program:

You might also like