Practical File
Practical File
CLASS – XI
PRACTICAL FILE – INFORMATICS PRACTICES
1. Write a program to obtain three numbers and print their sum.
Solution:
num1 = int( input ("Enter number 1 : "))
num2 = int( input("Enter number 2 : "))
num3 = int( input ("Enter number 3 : "))
Sum = num1 + num2 + num3
print(“Sum is :” Sum)
OUTPUT:
Enter number 1 : 1
Enter number 2 : 2
Enter number 3 : 3
Sum is : 6
2. Write a program to obtain length and breadth of a rectangle and calculate its area.
Solution:
length = float( input ("Enter length of the rectangle: "))
breadth = float( input ("Enter breadth of the rectangle: "))
area = length * breadth
print("Length=", length)
print("Breadth=", breadth)
print("Area=", area)
OUTPUT:
Enter length of the rectangle: 8.5
Enter breadth of the rectangle: 35
Length= 8.5
Breadth= 35.0
Area= 297.5
3. Write a program to input a number and print its cube.
Solution:
num=int(input("Enter a number:"))
cube=num*num*num
print("Number is:",num)
print("Cube is:",cube)
OUTPUT:
Enter a number: 5
Number is: 5
Cube is: 125
4. Write a program to input a value in kilometeres and convert into miles. (1 km = 0.621371
miles)
Solution:
km = int( input ("Enter kilometres : "))
miles = km * 0.621371
print("Kilometres :", km)
print("Miles : ", miles)
OUTPUT:
Enter kilometres : 15
Kilometres : 15
Miles : 9.320565
5. Write a program to calculate simple interest.
Solution:
principal_amt = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
simple_interest = (principal_amt*time*rate)/100
print('Simple interest is:',simple_interest)
OUTPUT:
Enter amount: 200000
Enter time: 2
Enter rate: 5.5
Simple interest is: 22000.0
6. Write a program to obtain temperature in Celsius and convert into Fahrenheit using the
formula: F= C*9/5+32
Solution:
cels = float (input ("Enter temp in Celsius :"))
print ("Temperature in Celsius is : ", cels)
f = cels * 9/5 + 32
print ("Temperature in Fahrenheit is : ", f)
OUTPUT:
Enter temp in Celsius :37
Temperature in Celsius is : 37.0
Temperature in Fahrenheit is : 98.6
8. Write a program to input age and check it is eligible for vote or not.
Solution:
age=int(input(‘Enter your age:’))
if age>=18:
print(‘Eligible to vote’)
else:
print(‘It is not eligible’)
OUTPUT:
Enter your age:25
Eligible to vote
9. Write a program to print a table of number of 5.
Solution:
num=5
for i in range(1,11,1):
print(num,'x',i,'=',num*i)
OUTPUT:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
OUTPUT:
Enter First Number: 10
Enter Second Number: 20
Value of num1 before swapping: 10
Value of num2 before swapping: 20
Value of num1 after swapping: 20
Value of num2 after swapping: 10
11. Write a program to input three integers and print the largest of the three.
Solution:
x=y=z=0
x= int (input("Enter first number :" ) )
y = int (input ( "Enter second number :" ) )
z = int (input("Enter third number :" ) )
max = x
if y > max :
max = y
if z > max :
max=z
print ("Largest number is", max)
OUTPUT:
Enter first number :25
Enter second number :30
Enter third number :63
Largest number is 63
12. Write a program to accept percentage from the user and display the grade according to
the following criteria:
Marks Grade
> 90 A
> 80 and <= 90 B
>= 60 and <= 80 C
below 60 D
Solution:
per = int(input("Enter marks"))
if per > 90:
print("Grade is A")
if per > 80 and per <=90:
print("Grade is B")
if per >=60 and per <= 80:
print("Grade is C")
if per < 60:
print("Grade is D")
OUTPUT:
Enter marks56
Grade is D
13. Write a program to create a list of any five colour names which has taken by user.
Solution:
a=[]
for i in range(5):
a.append(cl)
print(a)
OUTPUT:
14. Write a program in python which removes the last element from the list and insert it in
the beginning.
List : L = [1, 3, 2, 34, ‘amit’, 7, 5]
Solution:
L.insert(0, L.pop())
print(L)
OUTPUT:
OUTPUT:
dict_keys(['Anil', 'Mukesh', 'Dinesh'])
dict_values([50000, 60000, 65000])
OUTPUT:
Enter your age? 18
You are eligible to vote!!
17. The record of a student (Name, Roll No., Marks in five subjects and percentage of marks)
is stored in the following list:
Rec = [ ‘Raman’, ‘A-36’, [56,98,99,72,69], 78.8]
Write python statement to retrieve the following information from the list rec.
(a) Percentage of the student
OUTPUT:
(a) >>> rec[3]
78.8
18. Write a program to find the number of times an element occurs in the list.
Solution:
OUTPUT:
Enter element: 1
Solution:
for i in range(1,5):
for j in range(i):
print('*',end='')
print()
Solution:
numbers = [1,4,50,80,12]
max = 0
for n in numbers:
if(n>max):
max = n
print(max)
OUTPUT:
80