0% found this document useful (0 votes)
49 views23 pages

Prac Format 24 - 25

Uploaded by

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

Prac Format 24 - 25

Uploaded by

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

COMPUTER SCIENCE - PYTHON

Code No: 083


2024-25
PRACTICAL FILE

NAME:
CLASS & SECTION: 12/A
DELHI PRIVATE SCHOOL DUBAI

CERTIFICATE

Certified that this Practical file is the bona


fide work of Master / Miss ……. ……….
Class 12 Div A Roll No……... recorded in
the E-Learning Lab session during
academic year 2024 to 2025

____________________ ______________________ ____________________

Teacher in-Charge HOD External Examiner

Ms. Rose Nimmi Ms. Rose Nimmi


Acknowledgement

I would like to express my gratitude


and thanks to my Computer Science
faculty & HOD Ms. Rose Nimmi for her
guidance and unparalleled support
throughout the process of making my
Computer Science – Python practical
file.
I would also like to thank my Vice
Principal Ms. Sunita
Razdan and headmistress Ms. Blessy
and teachers for their patience and
help that has enabled me to finish this
practical file on time.
I’m obliged to the Principal, Ms.
Rashmi Nandkeolyar for providing me
with the opportunity and required
environment.
Finally, I would like to thank my family
and friends for giving me motivation
and support to go ahead with the
Practical file and its execution.
Index

S.NO TOPIC SIGNATURE


.

1
Review Of Python

2
User Defined Functions

3
File Handling

4
Data Structure (Stack)

5
SQL Group Functions

Python Interface with


6
MySQL
Review of
Python
INDEX
REVISION TOUR
S. No. PROGRAMS Teacher
Signature

Write a program to create a list that contains elements from two given
1. lists, with elements from the first list positioned at even indices and
elements from the second list positioned at odd indices:

Write a program to calculate the salary of employee based on below


condition:
2. If less than 1,00,000 Add 35% more
If >=1,00,000 and <2,00,000 Add 30% more
If >=2,00,000 Add 20% more

3. Write a program to display the sum of all values ending with 2.

Write a program to merge 2 dictionary elements of student and display


the merged dictionary.
student1_marks = {"S001": {"Math": 85, "Science": 90}, "S002":
4.
{"Math": 92, "Science": 88}}
student2_marks = {"S001": {"English": 88}, "S003": {"Math": 78,
"Science": 84}}

5. Write a Program to check if the entered number is Armstrong or not.

Write a Program to enter the number and print the Floyd’s Triangle in
6.
decreasing order.
Q)WAP to check if a number is negative or positive

A)
num = int(input("Enter A Number: "))
if num < 0:
print("Negative")
else:
print("Positive")

Output:
Enter A Number: 2
Positive
USER DEFINED
FUNCTIONS
IN
PYTHON
INDEX
USER DEFINED FUNCTIONS
Teacher
S. No. PROGRAMS
Signature

Write a function to find the sum of series:


1
(2) + (2+4) + (2+4+ 6) + ( 2 + 4 + 6 + 8) ……. Up to N terms

Write a Python function that takes a number as a parameter and checks


2
whether the number is prime or not.

Write a function to find the sum of series:


3
1 + 1/2^2 + 1/4^2 + 1/6^2 + 1/8^2 + ….. + 1/N^2

Write a function to find the sum of series:


4
1+ 1/3^2 + 1/5^2 + 1/7^2 + 1/9^2 + ….. + 1/N^2

Write a function that takes string as an argument and return the string if
5
its palindrome or not.

Write a menu driven program which calls 3 function :


6 Linear Search, minimum Number ,maximum number.
Function must take 2 argument a list and size default value as 7

Write a function which takes a number n as an argument and return the


7
factorial of a number.

Write a function that calculates the volume of a cylinder. The radius and
8
height are required arguments, while the units are optional.
FILE
HANDLING
INDEX

FILE HANDLING
Teacher
S. No. PROGRAMS
Signature

Write a program to read the content of file line by line and write it
1
to another file except for the lines contains “a” letter in it.

Write a program to read the content of file and display the total
2
number of consonants, uppercase, vowels and lower case characters.

Write a program to Program to create binary file to store Rollno,Name


3
and Marks and update marks of entered Rollno.

Write a program to create binary file to store Rollno and Name,


4 Search any Rollno and display name if Rollno found otherwise “Rollno
not found”.

Write a program to create CSV file and store empno, name, salary and
5 search for all names starting with ‘A’ and display name, salary and if
not found display appropriate message

Write a program to create CSV file and store empno, name, salary and
6 search for all names starting with ‘S’ with max 20 characters and
display name, salary and if not found display appropriate message.
DATA STRUCTURE

STACKS
INDEX
DATA STRUCTURE (STACKS)
Teacher
S. No. PROGRAMS
Signature

Write a program to create a stack called Student containing data values


1 roll number and name. Create functions push() for pushing data values,
pop() for removing data values and show() for displaying data values.

Write a menu driven program stack using list containing Employee


data:Employee Id(Eid) and Employee Name(Ename).
2 Push()
Pop()
Display()
Write a menu driven program implementing stack using list containing
book record:Book Number (Bno) and Book Name(Bname) .
3 Push()
Pop()
Display()
Write two functions push() to add and pop() to remove elements in
4 Directory using dictionary with fields pin code and name of city using
dictionary.
SQL GROUP

FUNCTIONS
INDEX
SQL GROUP FUNCTION
S. Teacher
No PROGRAMS Signatur
. e
Consider the table ITEM and CUSTOMER given below. Write SQL
commands in MySql for (1) to (4) and give output for SQL queries (5) to (8)
TABLE: ITEM

TABLE: CUSTOMER

A. SQL Commands:
1. To display the details of those customers whose city is Delhi
2. To display the details of those items whose Price is in the
range of 35000 to 55000.
3. To display the CustomerName and City from table Customer
and Itemname and Price from table Item, with their corresponding
matching I_Id.
4. To increase the Price of all items by 1000 in the table item
B. Output Queries:
5. SELECT DISTINCT(City) FROM Customer;
6. SELECT ItemName, MAX(Price), count(*) FROM item
GROUP BY ItemName;
7. SELECT CustomerName, Manufacturer
FROM Item,Customer WHERE Item.I_ID=Customer.I_ID;
SELECT ItemName, Price*100 FROM Item WHERE Manufacturer='ABC';

Consider the following tables DOCTOR and SALARY and write MySql
commands for the questions (1) to (4) and give output for SQL queries (5) to
2
(6)
TABLE: DOCTORS
TABLE: SALARY

A. SQL Commands:
1. Display NAME of all doctors who are in MEDICINE and
having more than 10 years from the table DOCTOR
2. Display the average salary of all doctors Working in “ENT”
department using the tables DOCTORS and SALARY.BASIC =
SALARY.BASIC + SALARY.ALLOWANCE
3. Display the minimum ALLOWANCE of female doctors
4. Display the highest consultation fee for Male doctors

B. Output Queries:

5. SELECT count(*) from DOCTORS where SEX= “F”;


SELECT NAME, DEPT, BASIC from DOCTORS, SALARY where DEPT = “ENT”
and DOCTORS.ID= SALARY.ID
Consider the following tables GARMENT and FABRIC and write MySql
commands for the questions (1) to (4) and give outputs for SQL queries (5) to
(8).
TABLE: GARMENT

TABLE: FABRIC

3
A. SQL Commands:
1. To display GCODE and DESCRIPTION of each GARMENT
in descending order of GCODE.
2. To display the details of all the GARMENTs, which have
READYDATE in between 08-DEC-07 and 16-JUN-08 (inclusive
of both dates).
3. To display the average PRICE of all the GARMENTs, which
are made up of FABRIC with FCODE as FO3.
4. To display FABRIC wise highest and lowest price of
GARMENTs from GARMENT table. (Display FCODE of each
GARMENT along with highest and lowest Price).
B. Output Queries:
5. SELECT SUM(PRICE) FROM GARMENT WHERE FCODE
= ‘F0l’;
6. SELECT DESCRIPTION, TYPE FROM GARMENT,
FABRIC WHERE GARMENT.FCODE = FABRIC.FCODE AND
GARMENT.PRICE >= 1260;
7. SELECT MAX(FCODE) FROM FABRIC;
SELECT COUNT(DISTINCT PRICE) FROM GARMENT;

Consider the following tables worker and paylevel and write MySql
4
commands for the questions (1) to (4) and give outputs for SQL queries (5) to
(8).
TABLE: worker

TABLE: paylevel

A. SQL Commands:
1. To display the details of all WORKERs in descending order of
DOB.
2. To display NAME and DESIGN of those WORKERs whose
PLEVEL is either P001 or P002.
3. To display the content of all the WORKERs table whose DOB
is in between ‘19-Jan-1984 and ’18-Jan-1987'.
4. To add a new row in WORKER table with the following data:
19, ‘Daya Kishore’, ‘Operator’, ‘P003’, 19-Jun-2008’, ’11-Jul-1984'
B. Output Queries:
5. SELECT COUNT (PLEVEL), PLEVEL FROM WORKER
GROUP BY PLEVEL;
6. SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
7. SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W.PLEVEL = P.PLEVEL AND W.ECODE<13;
8. SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL
WHERE PLEVEL = 'POO3';

5 Consider the following tables cabhub and customer and write MySql
commands for the questions (1) to (4) and give outputs for SQL queries (5) to
(8).

TABLE: cabhub

TABLE: customer
A. SQL Commands:
1. To display the names of all the white colored vehicles.
2. To display name of vehicle, make and capacity of all the
vehicles in ascending order of their sitting Capacity.
3. To display the highest charges at which a vehicle can be hired
from CABHUB.
4. To display all the Customer name and the corresponding name
of the vehicle hired by them.
B. Output Queries:
5. SELECT COUNT(DISTINCT Make) From CABHUB;
6. SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
7. SELECT COUNT(*), Make FROM CABHUB;
8. SELECT Vehicle FROM CABHUB WHERE Capacity=4;
PYTHON
INTERFACE
WITH MYSQL
INDEX
PYTHON INTERFACE WITH MYSQL
Teacher
S. No. PROGRAMS
Signature
Write a program to create and insert the data into the following table:
Field Name Data Type Constraints
Roll no Number Primary key
Name Char(20)
Sclass Varchar(5)
1
Age Number
Gender Char(10)
Date of Date DEFAULT
Joining SYSDATE
Percentage Float
Write a python interface programs using MySQL module using
following specifications of Student table. Use appropriate connection to
perform SQL query connections.
Field Name Data Type Constraints
Roll no Number Primary key
Name Char(20)
Sclass Varchar(5)
Age Number
Gender Char(10)
2 Date of Joining Date DEFAULT
SYSDATE
Percentage Float
Write a menu driven program
a)to insert n records from user
b) to delete record based on rollno
c)to fetch the records of student whose Date of joining is in the
month of June.
d) to display all records

Write a python interface programs using MySQL module using


following specifications of Employee table. Use appropriate connection
to perform SQL query connections.
Field Name Data Type Constraints
Emp No Number Primary key
Name Char(20)
Date of Joining Date DEFAULT
SYSDATE
Age Number
Address Char(10)
Salary Float DEFAULT
10000
3 Commission Float

You might also like