PRACTICAL FILE_X.
PRACTICAL FILE_X.
SCHOOL
ARTIFICIAL INTELLIGENCE
PRACTICAL FILE
Name:___________________________
Roll No.:____________________
Sn INDEX
o.
1 WAP to accept the length and breadth of a rectangle. Calculate and print its area
and perimeter.
WAP to calculate the distance covered by car if the speed and time is entered by user.
2
Write a Python program to accept the marks in five subjects. Print total and
3
average
4 WAP to find number of years and days if the total number of days are entered by
user.
5 WAP to accept the CP and SP of an article. Print whether it is profit or loss.
6 WAP to check whether no is even or odd.
7 WAP to enter the three sides of triangle and print it is equilateral triangle.
8 WAP to accept the percentage of student and print it is “PASS” or “FAIL”
9 WAP to print number from 1 to 10 using for loop.
10 WAP to print even numbers from 2 to 30 using for loop.
ar=l*b
p=2*(l+b)
OUTPUT
Enter the length:4
area of rectangle is 24
Perimeter of square is 20
********************************************************************************
PROGRAM:2
WAP to calculate the distance covered by car if the speed and time is entered by
user.
s=int(input(“Enter the speed”))
d=s*t
OUTPUT
Enter the speed:4
********************************************************************************
PROGRAM:3
Write a Python program to accept the marks in five subjects. Print total and
average
S1= int(input(“Enter the marks of first subject”))
Total=S1+S2+S3+S4+S5
Avg=total/5
OUTPUT
Enter the marks of first subject:56
yr=d/365
days_left=d%365
print(“No of year”,d)
print(“No of days left”, yr)
OUTPUT
Enter the total
days:725
No of year 2
No of days left 5
********************************************************************************
PROGRAM:5
if (cp>sp):
print(“LOSS”)
else:
print(“PROFIT”)
OUTPUT
PROFIT
********************************************************************************
PROGRAM:6
WAP to check whether no is even or odd.
n=int(input(“Enter the number:”))
if (n%2==0):
print(“NUMBER IS EVEN”)
else:
print(“NUMBER IS ODD”)
OUTPUT
NUMBER IS EVEN
NUMBER IS ODD
********************************************************************************
PROGRAM:7
WAP to enter the three sides of triangle and print it is equilateral triangle.
a=int(input(“Enter the first side:”))
if a==b==c:
print(“TRIANGLE IS EQUILATERAL”)
else:
OUTPUT
TRIANGLE IS EQUILATERAL
********************************************************************************
PROGRAM:8
WAP to accept the percentage of student and print it is “PASS” or “FAIL”
p=int(input(“Enter the percentage:”))
if (p>35):
print(“PASS”)
else:
print(“FAIL”)
OUTPUT
Enter the percentage:65
PASS
FAIL
********************************************************************************
PROGRAM:9
WAP to print number from 1 to n using for loop.
OUTPUT:
enter the number:4
1
2
3
4
********************************************************************************
PROGRAM:10
WAP to print even numbers from 2 to n using for loop.
OUTPUT:
enter the number:6
2
4
6
********************************************************************************
PROGRAM:11
OUTPUT:
enter the number:7
1
3
5
7
********************************************************************************
PROGRAM:12
WAP to print sum from 1 to n using for loop.
OUTPUT:
enter the number 4
TOTAL SUM IS 10
********************************************************************************
PROGRAM:13
WAP to print even numbers from 4 to n using while loop.
OUTPUT:
enter the number:10
4
6
8
*******************************************************************************
PROGRAM:14
WAP to print odd numbers from 3 to 10 using while loop.
OUTPUT:
enter the number:10
3
5
7
9
********************************************************************************
PROGRAM:15
WAP to create the list of n elements and elements are entered by user.
l=[]
n=int(input(“enter the number of elements”))
For I in range(n):
ele=int(input(“enter the element”))
l.append(ele)
print(l)
OUTPUT:
enter the number of elements 3
enter the element 7
enter the element 9
enter the element 12
[7,9,12]
********************************************************************************
PROGRAM:16
WAP to insert the new element at end of the list.
l=[6,18,22,19]
ele=int(input(“enter the element”))
l.append(ele)
print(l)
OUTPUT:
enter the element 45
[6,18,22,19,45]
PROGRAM:17
WAP to find the mean of the list,
l=[23,34,89,56]
n=sum(l)/len(l)
OUTPUT
Mean of list is:50.5
PROGRAM:18
WAP to insert the new list at the end of list.
l=[6,18,22,19]
l2=[67,87]
l.extend(l2)
print(l)
OUTPUT:
[6,18,22,19,67,87]
********************************************************************************
PROGRAM:19
WAP to print the total number of items present in the list.
l=[43,50,54,78, 54,78]
p=len(l)
OUTPUT
No of elements in list:6
********************************************************************************
PROGRAM:20
l=[90,50,54,8, 54,98]
p=max(l)
OUTPUT
********************************************************************************