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

Practical2023 24

Uploaded by

arry2605
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Practical2023 24

Uploaded by

arry2605
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

ARMY PUBLIC SCHOOL KAMARAJ ROAD

BANGALORE

INFORMATICS PRACTICES
RECORD WORK
2023-2024

CLASS XI

Page 1 of 16
INSTRUCTIONS:-

a) Use only Blue pen to write the Python programs.

b) Use Pencil for drawing / writing the output of Python programs/MySQL


commands.

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 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

Q 2 - 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: "))
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

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

Q 4 - 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 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

Q 7 -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:

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

Q 8 - 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)

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)

Q 10 - Program to print sum of natural numbers between 1 to n natural


numbers, where n is to be accepted from the user

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

Q 11 - 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 12 - 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

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)

Q 14- Program to calculate the factorial of a number(use while loop).

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

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- Program to create a list of elements by removing any duplicate elements
from the existing list.i.e all elements appearing multiple times in the list
should appear only once.
# List creation after removing duplicate elements
lst = eval(input("Enter input : "))
length = len(lst)
newList=[]
Page 10 of 16
for a in range(length):
if lst[a] not in newList:
newList.append(lst[a])
print("The new list without duplicates is:",newList)
Output-->
Enter input : [2, 4, 1, 3, 4, 7, 4]
The new list without duplicates is: [2, 4, 1, 3, 7]

Q 18- 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
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'}

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.

CREATE TABLE Student (RollNo int PRIMARY KEY, Name


varchar(30) NOT NULL, Class varchar(5) NOT NULL, Section char(1),
Gender char DEFAULT 'M' , DOB date , Marks decimal(5,2));

4. To insert the details of at least 3 students in the above table.


INSERT INTO STUDENT VALUES ( 1, 'Anshul Shrivastav', 'XI ', 'A',
'M', '2004-01-07 ', 92.31) , (2, 'Akshatha Kanavi', 'XI', 'D', 'F', '2003-12-13
', 98.00), (3, 'Dhanesh Khot', 'XI', 'E', 'M', '2004-10-24 ', 95.42);

5. To display the entire content of table.


SELECT * FROM Student;

6. To describe the structure of the table student


DESC Student;

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' ;

9. To display RollNo, Name, DOB, Marks of those male students in ascending


order of their names.

SELECT RollNo , Name, DOB , Marks FROM Student WHERE Gender =


'M' ORDER BY Name ASC ;

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.

SELECT RollNo, Gender, Name, DOB , Marks FROM Student ORDER


BY Marks DESC ;

12. Using IN operator display records of sections D and E.


SELECT * FROM Student WHERE Section IN ( 'D', 'E') ;

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;

15.To display the unique section available in the table.


SELECT DISTINCT Section 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";

18.Display only the first 5 records of the Student table


SELECT * FROM Student LIMIT 5 ;
Page 15 of 16
19.Add a column AdmNum char(10), this column should be added after Gender
ALTER TABLE Student ADD COLUMN AdmNum char(8);

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);

22.Delete those students who were born before 1 July 2004.


DELETE FROM Student WHERE DOB < "2004-07-01" ;

23.Change the Section as "D", Marks as "95" for RollNo 2.


UPDATE Student SET Section="D", Marks = 95 WHERE RollNo = 2;

24.Delete the table Student


DROP TABLE Student;

25. Drop the database named “School”


DROP DATABASE School;

******************************************************

Page 16 of 16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy