0% found this document useful (0 votes)
6 views

AI practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

AI practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PRACTICAL FILE STD 10 (2023-24)

(Please copy all these programs along with the output in the Practical file
NOTEBOOK)

Q. 1 Assign three variables with the same value and print it.

X=Y=Z=10 print(X,Y,Z)

OUTPUT:
10 10 10

Q.2 write a program to convert temperature from Fahrenheit to Celsius.


F=float(input("Enter temperature in Fahrenheit:"))
C=(F-32)*5/9
print("Temperature in Celsius:",C)

OUTPUT:
Enter temperature in Fahrenheit:100
Temperature in Celsius: 37.77777777777778
Q.3 Write a program to calculate simple interest. Accept Principle
amount, rate of interest and time from user. Display Simple Interest.

p=float(input("Enter principal Amount:"))


r=float(input("Enter rate of interest:"))
t=float(input("Enter number of years:"))
SI=(p*r*t)/100
print("Simple Interest=",SI)

OUTPUT:

Enter principal Amount:1000


Enter rate of interest:7
Enter number of years:5
Simple Interest= 350.0
Q.4 Accept two numbers from user and display the larger one.
x=int(input("Enter the first number:"))
y=int(input("Enter the second number:")) if
x>y :
print("The larger number is:", x)
else:
print("the larger number is:", y)

OUTPUT:
Enter the first number:10
Enter the second number:7
The larger number is: 10

Q.5 Write a program to print area of triangle, take base and height as
user input.
b=float(input("Enter base of a triangle:"))
h=float(input("Enter height of a triangle:"))
area=(b * h)/2
print("Area of triangle:", area)

OUTPUT:

Enter base of a triangle:6


Enter height of a triangle:7
Area of triangle: 21.0

Q.6 Write a program to accept age of a person and check his eligibility
of voting.
age= int(input("Enter your age:"))
if age>=18 :
print("You are eligible for voting.")
else:
print("You are not eligible for voting.")

OUTPUT:

Enter your age:17


You are not eligible for voting.
Q.7 write a program to ask the user to enter the stream and print all
the characters of the stream using for loop one below the other
str=input("Enter a string : ")
for x in str:
print(x)

OUTPUT:

Enter a string : python


p y t h o n
Q.8 Write a program to print the sum of n natural numbers. Accept n
from the user.
n=int(input("Enter a number:"))
sum=0
for x in range(n+1):
sum=sum+x
print("The sum of ",n,"natural numbers is:", sum)

OUTPUT:

Enter a number:7
The sum of 7 natural numbers is: 28

Q.9 Given list as L=['a','b','c','d','e']. Take input of index from the user
and remove that element using pop( ) function
L=['a','b','c','d','e']
print("Original List: ",L)
i=int(input("Enter the index of the element to be
removed: "))
L.pop(i)
print("List after removing element",L) Original
List: ['a', 'b', 'c', 'd', 'e']

OUTPUT:

Enter the index of the element to be removed: 3


List after removing element ['a', 'b', 'c', 'e']
Q.10 create a list of any 5 fruits and slice the last two elements using
negative indexing.
L=['Banana', 'Grapes','Apple','Orange','Melon']
print("Last two elements of the list are:", L[-2: ])

OUTPUT:

Last two elements of the list are: ['Orange','Melon']


Q.11 Create a list of vowels and print it

L = ['a','e,','i','o','u'] print(L)

OUTPUT:

['a', 'e,', 'i', 'o', 'u']


Q. 12 Create a list of 5 fruits and slice the middle 3 elements.
L=['Banana', 'Grapes','Apple','Pear','Mango']

print("The middle three elements:", L[1:4])

OUTPUT:

The middle three elements: ['Grapes', 'Apple','Pear']

Q.13 Create a tuple of any 5 elements of different data types.


t=(1,'abc',25.5,True,None) print("The
tuple is:--> ",t)

OUTPUT:

The tuple is:--> (1, 'abc', 25.5, True, None)

Q. 14 Write a program to input 2 numbers from the user and display


their addition, multiplication, subtraction and division.

n1=int(input("Enter the first number: "))


n2=int(input("Enter the second number: "))
print(" Addition =", n1+n2)
print(" Subtraction =", n1-n2)
print(" Multiplication =", n1*n2)
print(" Division=", n1/n2)
OUTPUT:

Enter the first number: 10


Enter the second number: 5
Addition = 15
Subtraction = 5
Multiplication = 50
Division= 2.0
Q15.Write a program to input the length and breadth of a rectangle and
display its area.
l=int(input(" Enter the length of a rectangle : "))

b=l=int(input(" Enter the breadth of a rectangle :"))

print("Area of rectangle:", l*b)


OUTPUT:

Enter the length of a rectangle : 7


Enter the breadth of a rectangle : 8
Area of rectangle: 64
Q16. Write a program to input the radius of a circle from the user and
display its area and circumference.

r=float(input("Enter radius of a circle: "))


pi=3.142
area= pi*r*r

cir =2*pi*r

print("Area of a circle is :", area)

print("Circumference of a circle : ",cir)


OUTPUT:

Enter redius of a circle: 5


Area of a circle is : 78.55
Circumference of a circle : 31.419999999999998
Q. 17 Write a program to accept a number from the user and print its
cube.
n=int(input("Enter a number: "))
print("Cube of a given number is : ", n*n*n)

OUTPUT:

Enter a number: 3
Cube of a given number is : 27
Q. 18 Write a program to accept a number from the user and display if
it is positive, negative or zero.
n=float(input("Enter a number:")) if
n>0:
print("The number is positive number") if
n<0:
print("The number is negative number") if
n==0:
print("The number is Zero")

OUTPUT:

Enter a number:34
The number is positive number

Q19. Write a program to accept a string from the user and print it in the
reverse order.
s=input("Enter a string: ")
print(s[:: -1])

OUTPUT:
Enter a string: Good Morning
gninroM dooG
Q20. Write a program to accept a string from the user and print its first
and last characters
s=input("Enter a string: ") print("The
first character is :", s[0]) print("The
last character is :", s[-1])

OUTPUT:
Enter a string: Python
The first character is : P
The last character is : n

You might also like