Practical File 2024-25

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

CH.

CHHABIL DASS PUBLIC SCHOOL, GHAZIABAD


Practical File Programs -2024-25
Class XII-CS (083)
General Instruction:
1. Each program should be started from new page.
2. Be careful for indentation and do proper documentations
_________________________________________________________________________________
SECTION – A ( PYTHON )
Q1. WAP to input total units which was consumed by a customer, calculate and
display total charged to be paid by the customer. Electric Bill charges will
calculate as per following condition.
No. of units Rate(in Rs)
First 100 Units 1 Rs per unit.
Next200 Units 2 Rs per unit.
Above300 Units 4 Rs per unit.
Q2. Write a menu driven program to calculate:
Area of circle[A=πr2]
Area of squire [A=a*a]
Area of rectangle[A=l*b]
Q3. Write a UDF in python , it will take a number as a function argument .
Function check and display whether the number if prime or not.
Q4. Write a UDF in python , it will take a number as a function argument .
Function calculate and display sum of each digit of that given number.
For example: number is 456, Sum is 4+5+6= 15
Q5. Write a program in python ,count and display the number of vowels,
consonants, uppercase, lower case characters in string.
Q6. Write a UDF in python, it will take three arguments list(sequence of elements),
its size and finding element . Function search and return 1 if element is
present in the given list otherwise return -1 . Using Binary search.

Q7. Write a program in python , to input a string check and display given string is
a palindrome or not.
Q8. Write a program in python, to create a number list. Search and display largest
and smallest number present in a list .Without using built-in function.

Q9. Write a program in python, to create a number list. Calculate and display sum
of those elements whose last digit is 5.

Q10. Write a program in python, to create two number lists a and b . Swap and
display all elements of both lists.

Page 1
Q11. Write a UDF in python, it will take a list as a function argument . Replace and
display first half elements with second half elements of a list.

For example: list elements are : 1 2 3 4 5

Output is : 4 5 3 1 2

Q12. Write a function in PYTHON that counts the number of “Me” or “My” words
present in a text file “DIARY.TXT”. If the “DIARY.TXT” contents are as follows:

My first book was Me and My


Family. It gave me chance to be
Known to the world.
The output of the function should be:
Count of Me/My in file: 4
Q13. Write a function in PYTHON to read the contents of a text file “Places.Txt” and
display all those lines on screen which are either starting with ‘P’ or with ‘S’.

Q14. Write a function EUCount() in PYTHON, which should read each character of a
text fileIMP.TXT, should count and display the occurrences of alphabets E and
U (including small cases e and u too).
Q15. Write a function in PYTHON to search for a BookNo from a binary file
“BOOK.DAT”, assuming the binary file is containing the records of the following
type: ("BookNo", "Book_name").Assume that BookNo is an integer.

Q16. Write a function in Python for PushS(List) and for PopS(List) for performing
Push and Pop operations with a stack of List containing integers.
Q17. Write a menu-driven program implementing user-defined functions to perform
different functions on a csv file “student” such as:
(a) Write a single record to csv.
(b) Write all the records in one single go onto the csv.
(c) Display the contents of the csv file.

Q18. Write a menu-driven program to perform all the basic operations using
dictionary on student binary file such as inserting, reading, updating,
searching and deleting a record.

Q19. Write a program to create a stack called student, to perform the basic
operations on stack using list. The list contains two data values called roll
number and name of student. Notice that the data manipulation operations
are performed as per the rules of a stack.

Page 2
Write the following functions :
• PUSH ( ) - To push the data values (roll no. and name) into the
stack.
• POP() - To remove the data values from the stack.
• SHOW() - To display the data values (roll no. and name) from the
stack.
Q20. ABC Infotech Pvt. Ltd. needs to store, retrieve and delete the records of its
employees. Develop an interface that provides front-end interaction through
Python, and stores and updates records using MySQL. The operations on
MySQL table “emp” involve reading, searching, updating and deleting the
records of employees.

(a) Program to read and fetch all the records from EMP table having salary
more than 70000.
(b) Program to update the records of employees by increasing salary by 1000 of
all those employees who are getting less than 80000.
(c) Program to delete the record on the basis of inputted salary.

SECTION –B (SQL)

Q1. Consider the tables EMPLOYEE and SALGRADE given below and answer (a) and
(b)parts of this question.

(a) Write SQL commands for the following statements:

(i) To display the details of all EMPLOYEEs in descending order of DOJ.

(ii) To display NAME and DESIG of those EMPLOYEEs whose SALGRADE is either S02 or S03.

(iii) To display the content of the entire EMPLOYEEs table, whose DOJ is in between ‘09-Feb-
2006’ and ‘08-Aug-2009’.

(iv) To add a new row with the following content:

109,‘Harish Roy’,‘HEAD-IT’,‘S02’,‘9-Sep-2007’,‘21-Apr-1983’

Page 3
(b) Give the output of the following SQL queries:

(i) SELECT COUNT(SGRADE),SGRADE FROM EMPLOYEE GROUP BY SGRADE;

(ii) SELECT MIN(DOB),MAX(DOJ) FROM EMPLOYEE;

(iii) SELECT SGRADE, SALARY+HRA FROM SALGRADE WHERE SGRADE =’S02’;

Q2. Study the following table and write SQL queries for questions (i) to (iv) and output for (v)

and (vi).

(i) Write SQL query to display Pname, Quantity and Rate for all the orders that are either

Pencil or Pen.

(ii) Write SQL query to display the orders which are not getting any Discount.

(iii) Write SQL query to display the Pname, Quantity and Sale_date for all the orders whose

total cost (Quantity * Rate) is greater than 500.

(iv) Write SQL query to display the orders whose Rate is in the range 20 to 100.

(v) SELECT Pname, Quantity from Orders WHERE Pname LIKE(‘_e%’);

(vi) SELECT Pname, Quantity, Rate FROM Orders Order BY Quantity DESC;

Q3. Write SQL commands for (i) to (vi) on the basis of relations given below:

(i) To show the books of FIRST PUBL. Publishers written by P. Purohit.

(ii) To display cost of all the books published for FIRST PUBL.
Page 4
(iii) Depreciate the price of all books of EPB publishers by 5%.

(iv) To display the BOOK_NAME and price of the books, more than 3 copies of which have

been issued.

(v) To show total cost of books of each type.

(vi) To show the details of the costliest book.

Q4. Consider the given table and answer the questions.

(i) To show all information of students where capacity is more than the no. of students in
order of rtno.
(ii) To show area_covered for buses covering more than 20 km., but charges less than
80000.
(iii) To show transporter-wise total no. of students travelling.
(iv) To show rtno, area_covered and average cost per student for all routes where average cost
per student is—charges/noofstudents.
(v) Add a new record with the following data:
(11, “Motibagh”,35,32,10, “kisan tours”, 35000)
(vi)Give the output considering the original relation as given:
(a) select sum(distance) from schoolbus where transporter= “Yadav travels”;
(b) select min(noofstudents) from schoolbus;
(c) select avg(charges) from schoolbus where transporter= “Anand travels”;
(d) select distinct transporter from schoolbus;

Page 5

You might also like