ARMY PUBLIC SCHOOL KAMARAJ ROAD
BANGALORE
INFORMATICS PRACTICES
RECORD WORK
2021-2022
CLASS XI
Page 1 of 12
INSTRUCTIONS:-
a) Use only Blue pen to write the Python programs.
b) Use Pencil for drawing / writing the output of Python programs.
c) The output to be drawn / written on the plain page of the record book.
d) All pages to be numbered in the record.
e) Each and every python program should be written on a separate page.
f) Follow the index as per the below mentioned index data. The date of experiment
to be left blank for the time being.
INDEX DATA
Exp No Name of the Experiment
1 Calculate perimeter and area of a square
2 Calculate area and circumference of a circle
3 Find the total and percentage of five marks
4 Calculate Simple Interest
5 Program to repeat the given string
6 Convert the given temperature in Celsius into Fehrenheit value
7 Find the square and cube of a given number n
8 Check whether the given number is odd or even.
9 Find average and grade for given marks.
10 To calculate profit-loss for given Cost and Sell Price
11 Discount calculator
12 Print sum of natural numbers
13 Factorial of first n natural numbers
14 Sum of odd numbers between 1 and n
15 Display even numbers in descending order
16 Search for an element from the given list of numbers
17 Create a dictionary to names of states and their capitals
18 Create a dictionary of students and their marks.
Page 2 of 12
PYTHON PROGRAMS
Q 1 - Write a Python program to calculate perimeter and area of a square
#To find the area and perimeter of a square
side = int(input( "Enter the side length of a square" ))
#calculate area
area = side * side
# calculate perimeter
perimeter = 4 * side
print( "Area of the square is :" , area)
print( "Perimeter of the square is :" , perimeter)
Output -->
Enter the side length of a square 5
Area of the square is : 25
Perimeter of the square is : 20
Q 2 - Write a Python program to calculate area and circumference of a circle
# To find Area and Circumference Of a Circle
PI = 3.14
radius = float(input('Enter the radius of a circle: '))
area = PI * radius * radius
circumference = 2 * PI * radius
print (" Area of the circle : " , area)
print (" Circumference of the circle : " , circumference)
Output-->
Enter the radius of a circle: 5
Area Of a Circle : 78.5
Circumference Of a Circle : 31.40
Q 3 - Write a program to find the total and percentage of five marks.
#Program to find the total and percentage of five marks
eng = float(input("Enter English marks: "))
Page 3 of 12
hin = float(input ("Enter Hindi marks: "))
mat = float(input ("Enter Maths marks: "))
sci = float(input ("Enter Science marks: "))
sst = float(input ("Enter SST marks: "))
total = eng + hin + mat + sci + sst
per = total / 5
print("Total marks is: ", total)
print("Percentage is: ", per)
Output -->
Enter English marks: 60
Enter Hindi marks: 70
Enter Maths marks: 65
Enter Science marks: 55
Enter SST marks: 78
Total marks is: 328.0
Percentage is: 65.6
Q 4 - Write a program to calculate Simple Interest.
SI = ( P X R X T ) / 100
P , R and T are given as input to the program
# Simple Interest
P = float( input ( "Enter Principal amount : "))
R = float( input ("Enter rate of interest : "))
T = float( input ("Enter time in years : "))
SI = ( P * R * T ) / 100
print("Simple Interest is : ", SI)
Output-->
Enter Principal amount : 1000
Enter rate of interest : 20
Enter time in years : 2
Simple Interest is : 400.0
Q 5 - Write a program to repeat the string "I AM THE BEST" n [Link],
'n' is an integer entered by the user.
# Program to print the text multiple times
Page 4 of 12
n = int(input("How many times ? "))
print("I AM THE BEST" * n)
Output-->
How many times ? 2
I AM THE BESTI AM THE BEST
Q 6 - Write a program to convert the given temperature in Celsius into
Fehrenheit value, Celsius is a numeric value entered by the user.
# Celsius to Fahrenheit conversion
Celsius = int(input("Enter a temperature in Celsius: "))
Fahrenheit = (9.0/5.0 * Celsius) + 32
print("Temperature:", Celsius, "Celsius is equal to ", Fahrenheit, " F")
Output-->
Enter a temperature in Celsius: 37
Temperature: 37 Celsius is equal to 98.60 F
Q 7 - Write a program to find the square and cube of a given number n. Here,
n is given by the user.
# To find square and cube of a number
num = int(input("Enter a number : "))
sq = num * num
cube = num * num * num
print("Square of the number is : ", sq)
print("Cube of the number is : ", cube)
Output -->
Enter a number : 2
Square of the number is : 4
Cube of the number is : 8
Q 8 - Program to take a number and check whether the given number is odd
or even.
num = int ( input ( "Enter an integer: "))
if num % 2 == 0:
print( num , " is EVEN number ")
Page 5 of 12
else:
print( num , " is ODD number")
Output-->
Enter an integer: 22
22 is EVEN number
Enter an integer: 23
23 is ODD number
Q 9 -To find average and grade for given marks.
# To find the average and grade for given marks
marks1=float(input("Enter marks1 "))
marks2=float(input("Enter marks2 "))
marks3=float(input("Enter marks3 "))
marks4=float(input("Enter marks4 "))
marks5=float(input("Enter marks5 "))
avgMarks = (marks1 + marks2 + marks3 + marks4 + marks5)/5
print("Students average marks is ", avgMarks)
if avgMarks <= 100 and avgMarks >90:
print("Student scored A+ grade")
elif avgMarks <= 90 and avgMarks >80:
print("Student scored A grade")
elif avgMarks <= 80 and avgMarks >60:
print("Student scored B grade")
elif avgMarks <= 60 and avgMarks >40:
print("Student scored D grade")
elif avgMarks <= 40 and avgMarks >30:
print("Student scored E grade")
Page 6 of 12
elif avgMarks <= 30:
print("Student failed in the exam")
else:
print("Invalid marks")
Output -->
Enter marks1 50
Enter marks2 70
Enter marks3 60
Enter marks4 85
Enter marks5 75
Students average marks is 68.0
Student scored B grade
Q 10 - To calculate profit-loss for given Cost and Sell Price.
# To calculate profit-loss for given Cost and Sell Price.
CP = float(input("Please Enter the Cost Price of the product: "))
SP = float(input("Please Enter the Sale Price of the product: "))
if CP > SP :
amount = CP - SP
print("Total Loss is ", amount)
elif SP > CP:
amount = SP - CP
print("Total Profit is " , amount)
else:
print("There is no Profit no Loss")
Output -->
Please Enter the Cost Price of the product: 45
Page 7 of 12
Please Enter the Sale Price of the product: 56
Total Profit is 11.0
Q 11 - Accept Cost and qty from the user, find the total , apply 10% discount
on total if the total exceeds 1000 , else 5% discount , finally display the total ,
discount and net amt , net amt = total – disc
# Discount calculator program
cost = float(input("Enter the cost of the item : "))
qty = int(input("Enter the item quantity"))
totAmt = cost * qty
if totAmt > 1000 :
discount = totAmt * ( 10 /100 )
else:
discount = totAmt * ( 5 / 100 )
netAmt = totAmt - discount
print("The total amount is : ", totAmt)
print("The discount given is : ", discount)
print("The net amount is : ", netAmt)
Q 12 - Program to print sum of natural numbers between 1 to n natural
numbers, where n is to be accepted from the user
# To print the sum of natural numbers between 1 to n
n = int(input("Enter the value of n"))
res = 0
for i in range ( 1, n + 1 , 1) :
res = res + i
print( " Sum of natural numbers <= ", n , " is ", res)
Output-->
Enter the value of n 7
Sum of natural numbers <= 7 is 28
Page 8 of 12
Q 13 - Program to find the factorial of first n natural numbers.
# To calculate the factorial of given number n
n = int(input("Enter the value of n"))
fact = 1
for i in range(1 , n + 1 , 1) :
fact = fact * i
print(fact)
Output-->
Enter the value of n 4
24
Q 14 - Find the sum of odd numbers between 1 and n , where n is to be
accepted from the user ( use for loop )
# Program to find sum of odd numbers between 1 and n
num = int(input("Print sum of odd numbers till : "))
Sum = 0;
for i in range( 1 , num + 1):
if (( i % 2) != 0):
Sum = Sum + i
print(Sum)
Output-->
Print sum of odd numbers till : 11
36
Q 15 - Program to display the following numbers series using for loop:-
10
8
6
4
2
# To display even numbers in descending order ( 10 to 2)
for i in range ( 10 , 1 , -2):
print(i)
Page 9 of 12
Q 16 - Program to search for an element from the given list of numbers:-
lst = eval(input("Enter input : "))
length = len(lst)
element = int(input("Enter element to be searched for: "))
flag = False
ele_index = None
for i in range( 0, length) :
if element == lst[i]:
flag = True
ele_index = i
if flag == True:
print("Element found at index location ", ele_index)
else:
print("Element not present in the given list")
Output-->
Enter input : [2,3,5,7,12,1]
Enter element to be searched for: 7
Element found at index location 3
Q 17- Create a dictionary to store names of states and their capitals.
# Dictionary to store names of states and their capitals.
n = int(input("How many states : "))
capitalInfo = {}
for a in range(n) :
key = input("Enter the state name")
value = input("Enter the state capital : ")
capitalInfo[key] = value
Page 10 of 12
print(" The dictionary is : ")
print(capitalInfo)
Output-->
How many states : 2
Enter the state name Maharashtra
Enter the state capital : Mumbai
Enter the state name Assam
Enter the state capital : Dispur
The dictionary is :
{' Maharashtra': 'Mumbai', ' Assam': 'Dispur'}
Q 18 -Create a dictionary of students to store names and marks obtained in 5
subjects.
#Dictionary of students to store names and marks obtained in 5 subjects.
n = int(input("Enter number of students : "))
studentInfo = {}
for a in range(n) :
key = input("Enter the student's name")
value = int(input("Enter the marks obtanined : "))
studentInfo[key] = value
print(" The dictionary is : ")
print(studentInfo)
Output-->
Enter number of students : 2
Enter the student's name Shlok
Enter the marks obtanined : 74
Enter the student's name Anita
Page 11 of 12
Enter the marks obtanined : 85
The dictionary is :
{' Shlok': 74, ' Anita': 85}
******************************************************
Page 12 of 12