Practical2023 24
Practical2023 24
BANGALORE
INFORMATICS PRACTICES
RECORD WORK
2023-2024
CLASS XI
Page 1 of 16
INSTRUCTIONS:-
c) The output to be drawn / written on the plain page of the record book.
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 area and circumference of a circle
2 Find the total and percentage of five marks
3 Calculate Simple Interest
4 Convert the given temperature in Celsius into Fehrenheit value
5 Find the square and cube of a given number n
6 Check whether the given number is odd or even.
7 Find average and grade for given marks.
8 To calculate profit-loss for given Cost and Sell Price
9 Discount calculator
10 Print sum of natural numbers
11 Factorial of first n natural numbers(for loop)
12 Sum of odd numbers between 1 and n
13 Display even numbers in descending order
14 Calculate the factorial of a number(while loop)
15 Calculate and print the sums of even and odd integers
16 Search for an element from the given list of numbers
17 To remove duplicate elements from the list
18 Create a dictionary to names of states and their capitals
19 Create a dictionary of students and their marks.
20 To remove an existing element from the dictionary
21 MySQL Commands
Page 2 of 16
PYTHON PROGRAMS
Q 1- 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
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
Page 3 of 16
Q 3 - 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
Output-->
Enter a temperature in Celsius: 37
Temperature: 37 Celsius is equal to 98.60 F
Q 5- 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
Page 4 of 16
Square of the number is : 4
Cube of the number is : 8
Q 6 - 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 ")
else:
print( num , " is ODD number")
Output-->
Enter an integer: 22
22 is EVEN number
Enter an integer: 23
23 is ODD number
Page 5 of 16
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")
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
Page 6 of 16
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
Please Enter the Sale Price of the product: 56
Total Profit is 11.0
Q 9 - 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)
Page 7 of 16
# 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 16
Q 13 - 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)
OUTPUT
Enter a number:4
The factorial of 4 is 24
Q 15- Program to calculate and print the sums of even and odd integers of the
first n natural numbers
OUTPUT
Upto which natural number? 4
Page 9 of 16
The sum of even integers is 6
The sum of odd integers is 4
Page 11 of 16
Q 19 -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
Enter the marks obtanined : 85
The dictionary is :
{' Shlok': 74, ' Anita': 85}
Q 20- Program to create a dictionary called Friends by setting Rollno as keys
and Name as value and print the dictionary values only. Also write the code to
delete a particular element from the dictionary.
n = int(input("Enter number of students : "))
sInfo = {}
for a in range(n) :
key = int(input("Enter the student's roll number: "))
value = input("Enter the Name : ")
Page 12 of 16
sInfo[key] = value
print(" The dictionary is : ")
print(sInfo)
print("The values of the dictionary are: ")
print(sInfo.values())
ele = int(input("Enter the Roll no of the student to be deleted: "))
del sInfo[ele]
print("The updated dictionary is :", sInfo)
Output-->
Enter number of students : 3
Enter the student's roll number: 1
Enter the Name : Ajay
Enter the student's roll number: 2
Enter the Name : Beena
Enter the student's roll number: 3
Enter the Name : Dhanush
The dictionary is :
{1: 'Ajay', 2: 'Beena', 3: 'Dhanush'}
The values of the dictionary are:
dict_values(['Ajay', 'Beena', 'Dhanush'])
Enter the Roll no of the student to be deleted: 2
The updated dictionary is : {1: 'Ajay', 3: 'Dhanush'}
MYSQL COMMANDS
1. To create a database "School"
CREATE DATABASE SCHOOL;
Page 13 of 16
2. To activate the database "School"
USE School;
3. To create student table with the student id, class, section, gender, name, dob,
and marks as attributes where the student id is the primary key.
Table Name :- Student
FieldName Datatype Constraint Description
RollNo Int Primary Key Student Roll No
Name Varchar(30) Not Null Student Name
Class Varchar(5) Not Null Class details
Section Char(1) Section details
Gender Char(1) Default 'M' Gender info
DOB Date Date of birth
Marks Decimal(5,2) Marks info
Note:- Draw the above given table on the plain side/page of the record
book.
7. To display the information all the students, whose name starts with ‘AN’
(Examples: ANAND, ANGAD,..)
SELECT * FROM Student WHERE Name LIKE "AN%" ;
8. To display RollNo, Name, DOB of those students who are born between ‘2003-
01-01’ and ‘2004-06-31’ (both inclusive).
Page 14 of 16
SELECT RollNo, Name, DOB FROM Student WHERE DOB BETWEEN
'2003-01-01' AND '2004-06-31' ;
10.Select the records having the student marks > 60 and < 95.
SELECT * FROM Student WHERE Marks > 60 AND Marks <95 ;
11.To display RollNo, Gender, Name, DOB, Marks in descending order of their
marks.
13. Display the records of the student table for which the Marks data is not
available
SELECT * FROM Student WHERE Marks IS NULL ;
14. To display the Name and Marks, wherever there is no Mark, display it as 75.
SELECT Name, IFNULL( Marks, 75) FROM Student;
16. Display the RollNo, Name and Marks , display Marks as “Total Marks”
SELECT RollNo, Name, Marks as "Total Marks" FROM Student ;
17.Display the Student details who belongs to either Section 'D' or 'E'.
SELECT * FROM Student WHERE Section = "D" or Section = "E";
20.Increase the marks by 5% for those students who have scored less that 33
marks.
UPDATE Student SET Marks = Marks + (5/100)* Marks WHERE Marks
< 33;
21.Increase the size of the gender column to 10
ALTER TABLE Student CHANGE Gender Gender char(10);
******************************************************
Page 16 of 16