Wednesday, 26 August 2026

GRADE 12 - LAB 18 - Aug 27 2026

 GRADE 12 - LAB 18


'''WAP using Python-MySQL connectivity to create the given

table and insert values. Create a menu driven program for :


MENU:

1.DISPLAY ONE RECORD

2.DISPLAY ALL RECORDS

3.DISPLAY DESIRED NUMBER OF RECORDS

4.DISPLAY TOTAL NUMBER OF ROWS

5.UPDATE SALARY

6.DELETE RECORD

7.SEARCH EMPLOYEES WITH SALARY ABOVE RS. 50000


TABLE : EMPLOYEE


+-------+---------------+---------+--------+------+------------+

| EOCDE | ENAME         | DEPCODE | salary | AGE  | JOINDATE   |

+-------+---------------+---------+--------+------+------------+

|    15 | SAMEER SHARMA |     123 |  75000 |   39 | 2007-04-01 |

|    21 | RAGVINDER K   |     101 |  86000 |   29 | 2005-11-11 |

|    34 | RAMA GUPTA    |     119 |  52500 |   43 | 2010-02-03 |

|    46 | C R MENON     |     103 |  67000 |   38 | 2004-07-12 |

|    77 | MOHAN KUMAR   |     103 |  63000 |   55 | 2000-11-25 |

|    81 | RAJESH KUMAR  |     119 |  74500 |   48 | 2008-12-11 |

|    89 | SANJEEV P     |     101 |  92600 |   54 | 2009-01-12 |

|    93 | PRAGYA JAIN   |     123 |  32000 |   29 | 2006-08-05 |

+-------+---------------+---------+--------+------+------------+



(15,'SAMEER SHARMA',123,75000,39,'2007-04-01'),

(21,'RAGVINDER K',101,86000,29,'2005-11-11'),

(34,'RAMA GUPTA',119,52500,43,'2010-02-03'),

(46,'C R MENON',103,67000,38,'2004-07-12'),

(77,'MOHAN KUMAR',103,63000,55,'2000-11-25'),

(81,'RAJESH KUMAR',119,74500,48,'2008-12-11'),

(89,'SANJEEV P',101,92600,54,'2009-01-12'),

(93,'PRAGYA JAIN',123,32000,29,'2006-08-05')



def menu():

    while True :

        ch=int (input("""

1.DISPLAY ONE RECORD

2.DISPLAY ALL RECORDS

3.DISPLAY DESIRED NUMBER OF RECORDS

4.DISPLAY TOTAL NUMBER OF ROWS

5.UPDATE SALARY

6.DELETE RECORD

7.SEARCH EMPLOYEES WITH SALARY ABOVE RS. 50000

8.EXIT

YOUR CHOICE : """))

        if ch==1:

            disp_one()

        elif ch==2:

            disp_all()

        elif ch==3:

            disp_many()

        elif ch==4:

            tot_rows()

        elif ch==5:

            update()

        elif ch==6:

            delete()

        elif ch==7:

            search()

        else :

            break


def disp_one():

         pass


def disp_many():

  pass

def disp_all():

    pass


def tot_rows():

    pass


def update():

    pass


def delete():

    pass


def search():

pass    


menu()


Wednesday, 19 August 2026

GRADE 12 - LAB 17 - 20th aug 2026

Consider the tables dept and employee alongside. Create the tables accordingly and write SQL Queries for the same : 


Employee


+------+--------------+------------+------------+--------+-------+------------+

| eno  | name         | doj        | dob        | gender | dcode | salary     |

+------+--------------+------------+------------+--------+-------+------------+

| 1001 | george k     | 2013-09-02 | 1991-09-01 | male   | d01   | 1000000.00 |

| 1002 | ryma sen     | 2012-12-15 | 1990-12-15 | female | d03   | 1500000.00 |

| 1003 | mohitesh     | 2013-02-03 | 1987-09-04 | male   | d05   | 1200000.00 |

| 1004 | manila sahai | 2012-12-09 | 1986-11-14 | female | d01   | 1300000.00 |

| 1005 | r sahay      | 2013-11-18 | 1987-03-31 | male   | d02   | 1400000.00 |

| 1006 | jaya priya   | 2014-06-09 | 1985-06-23 | female | d05   | 1100000.00 |

| 1007 | anil jha     | 2014-01-17 | 1984-10-19 | male   | d04   | 1400000.00 |

+------+--------------+------------+------------+--------+-------+------------+


Dept


+-------+----------------+----------+

| dcode | department     | location |

+-------+----------------+----------+

| d01   | infrastructure | delhi    |

| d02   | marketing      | delhi    |

| d03   | media          | mumbai   |

| d04   | human resource | mumbai   |

| d05   | finance        | kolkata  |

+-------+----------------+----------+

CREATE DATABASE Lab17;

USE Lab18;


CREATE TABLE DEPT (

    dcode CHAR(3) PRIMARY KEY,

    department VARCHAR(30),

    location VARCHAR(30)

);


INSERT INTO DEPT VALUES

('d01', 'infrastructure', 'delhi'),

('d02', 'marketing', 'delhi'),

('d03', 'media', 'mumbai'),

('d04', 'human resource', 'mumbai'),

('d05', 'finance', 'kolkata');


CREATE TABLE EMPLOYEE (

    eno INT PRIMARY KEY,

    name VARCHAR(30),

    doj DATE,

    dob DATE,

    gender CHAR(6),

    dcode CHAR(3),

    salary DECIMAL(12, 2),

    CONSTRAINT fk FOREIGN KEY (dcode) REFERENCES DEPT (dcode)

);


INSERT INTO EMPLOYEE VALUES

(1001, 'George K', '2013-09-02', '1991-09-01', 'male', 'd01', 1000000.00),

(1002, 'Ryma Sen', '2012-12-15', '1990-12-15', 'female', 'd03', 1500000.00),

(1003, 'Mohitesh', '2013-02-03', '1987-09-04', 'male', 'd05', 1200000.00),

(1004, 'Manila Sahai', '2012-12-09', '1986-11-14', 'female', 'd01', 1300000.00),

(1005, 'R Sahay', '2013-11-18', '1987-03-31', 'male', 'd02', 1400000.00),

(1006, 'Jaya Priya', '2014-06-09', '1985-06-23', 'female', 'd05', 1100000.00),

(1007, 'Anil Jha', '2014-01-17', '1984-10-19', 'male', 'd04', 1400000.00);



i) Display Eno, Name, Gender, Dob from the Table Employee in ascending order of age.


ii) To display the name of all male employees from the table employee who were born in the year 1987


iii) To display the count of male and female employees with the headings as gender, and count.


iv) To display the eno and name of all employees who were born between ‘ 1987-01-01’ and ‘1991-12-01’ , the oldest first.


v) Display Name and department of each employee.


vi)Display the count of employees and average salary(rounded to nearest integer) in each department.


vii) Display the employee no, name , location and salary of the employees who work at Mumbai or Delhi and have a salary of more than 1300000.


viii) Display each city and the average salary of corresponding employees where the average salary is greater than 1200000. 


ix) Increase the salary of female employees by 15% and male employees by 12%


x) Display the details (eno, name, salary) of the employee(s) receiving the highest salary in the company.


xi) Display the department code (dcode) and the total salary paid to employees in that department, but only for departments where the total salary exceeds 2000000.


xii)Display the name and salary of all employees who work in the 'delhi' location.


xiii)Display the gender and average salary for each gender, showing only those groups whose average salary is greater than 1250000.


xiv) Display the names of all employees who belong to either the 'infrastructure' or 'finance' department.


xv) Delete all employees from the EMPLOYEE table who work in the 'media' department.



What is the output of the following queries?


i)Select  dcode,count(*) from employee group by dcode having count(*) >1;

ii)Select name, department from employee e, dept d where e.dcode = d.dcode and eno <1003;

iii) Select max(doj),min(dob) from employee;

Monday, 10 August 2026

stack practice

 A stack, named ClrStack, contains records of some colors. Each

record is represented as a tuple containing four elements -

ColorName, RED, GREEN, BLUE. For example, ('Yellow', 237, 250, 68).

Write the following user-defined functions in Python to

perform the specified operations on ClrStack:

(i) push_Clr(ClrStack, new_Clr): This function takes the stack

ClrStack and a new record new_Clr as arguments and pushes this new

record onto the stack.

(ii) pop_Clr(ClrStack): This function pops the topmost record from the

stack and returns it. If the stack is already empty, the function

should display the message "Underflow".

(iii) isEmpty(ClrStack): This function checks whether the stack is

empty. If the stack is empty, the function should return True,

otherwise the function should return False

(iv) display(ClrStack): This function to display all the elements of

the stack by popping it. In the end it should display "Stack Empty"

Sunday, 9 August 2026

GRADE 12 : PRACTICAL 16 : 17th August 2026

 Create the below tables and perform the required queries:


FURNITURE:


+----+-----------------+--------------+-------------+----------+----------+

| no | itemname        | type         | dateofstock | price    | discount |

+----+-----------------+--------------+-------------+----------+----------+

|  1 | dolphin         | baby cot     | 19-02-2002  |  9500.00 |       20 |

|  2 | decent          | office table | 01-01-2002  | 25000.00 |       30 |

|  3 | comfort zone    | double bed   | 12-01-2002  | 25000.00 |       25 |

|  4 | donald          | baby cot     | 24-02-2002  |  6500.00 |       15 |

|  5 | royal finish    | office table | 20-02-2002  | 18000.00 |       90 |

|  6 | royal tiger     | sofa         | 22-02-2002  | 31000.00 |       30 |

|  7 | economy sitting | sofa         | 13-12-2001  |  9500.00 |       25 |

|  8 | eating paradise | dining table | 19-02-2002  | 11500.00 |       25 |

+----+-----------------+--------------+-------------+----------+----------+  


ARRIVALS:


+----+--------------+------------+-------------+----------+----------+

| no | itemname     | type       | dateofstock | price    | discount |

+----+--------------+------------+-------------+----------+----------+

|  1 | wood comfort | double bed | 23-03-2003  | 25000.00 |       25 |

|  2 | old fox      | sofa       | 20-03-2003  | 17000.00 |       20 |

|  3 | micky        | baby cot   | 1-4-2003    |  7500.00 |       15 |

+----+--------------+------------+-------------+----------+----------+



1)Show all the information about baby cots from the furniture table 2)To list the itemname which are priced at more than 15000 from the furniture table with a heading as ‘Highend_items’ 3)To list itemnames and types of those items in which date of stock is before 22/02/2002 from the furniture table in descending order of the item name 4)To display item name and date of stock of those items in which the discount percentage is less than 20 or more than 25. 5)To display the item type and corresponding count. 6) Insert all the rows from arrivals into the furniture table
7) Delete all the rows from Arrivals table; 8) Display item no, item name, mrp and the discounted price for all items 9) Display all the furniture types that have an average discount percent greater than 20.

10) Display item details whose names start with 'royal' or end with 'comfort'.

11) Display items from furniture whose price is above the average price of all items.

12) Combine all unique item types available in the FURNITURE table.

13) Display the item name and price of the item(s) that have the highest price in the FURNITURE table.

14) Display the item name, price, and year of stock for all items stocked during the year 2002

Wednesday, 5 August 2026

grade 12 : lab 15 : 7th Aug 2026

 GRADE 12 - LAB 15

Write query commands for the following based on tables doctor and doc_dept .


DOCTOR


+------+------------------+--------+-----+------------+----------+

| d_id | dname            | gender | age | mobile     | salary   |

+------+------------------+--------+-----+------------+----------+

| d123 | swati garg       | f      |  35 | 9873214560 | 85000.00 |

| d234 | anirudh          | m      |  40 | 9874563210 | 91000.00 |

| d334 | Deepak           | m      |  45 | 9988774455 | 85400.00 |

| d456 | rupinder kaur    | f      |  32 | 9632587410 | 95850.00 |

| d656 | shailender gupta | m      |  42 | 9102365478 | 98750.00 |

| d734 | yashika lamba    | f      |  39 | 9899552223 | 75300.00 |

+------+------------------+--------+-----+------------+----------+


DOC_DEPT


+------+-------------+---------+----------+

| d_id | department  | charges | opd_days |

+------+-------------+---------+----------+

| d123 | gynaecology |  700.00 | mwf      |

| d234 | cardiology  |  850.00 | mwf      |

| d456 | gynaecology |  700.00 | tts      |

| d656 | cardiology  |  850.00 | mwf      |

| d734 | ent         |  900.00 | tts      |

| d334 | neurology   |  950.00 | tts      |

+------+-------------+---------+----------+


create table doctor(

d_id char(4) primary key,

dname varchar(25),

gender char(1) check(gender in ("M","F")),

age int,

mobile decimal(10),

salary decimal(7,2));


insert into doctor values

("d123","Swati Garg","F",35,9873214560,85000.00),

("d234","Anirudh","M",40,9874563210,91000.00),

("d334","Deepal","M",45,9988774455,85400.00),

("d456","Rupinder Kaur","F",32,9632587910,95850.00),

("d656","Shailendar Gupta","M",42,9102365478,98750.00),

("d734","Yashika Lamba","F",39,9899552223,75300.00);


create table doc_dept(

d_id char(4) primary key references doctor(d_id),

department varchar(20),

charges decimal(10,2),

opd_days varchar(7));


insert into doc_dept values

("d123","Gynaecology",700.00,"mwf"),

("d234","Cardiology",850.00,"mwf"),

("d456","Gynaecology",700.00,"tts"),

("d656","Cardiology",850.00,"mwf"),

("d734","ENT",900.00,"tts"),

("d334","Neurology",950.00,"tts");



i)Display id, name, department, mobile number, and charges from the above table.

ii) Display dname, department name, charges of opd_days mwf

iii)Display the total salary of the doctors department wise

iv)Increase the charges of the neurology, ent department to 20%

v)Show the details of the male doctors whose age is between 40 to 50  and have opd_days on MWF

vi)Display the average age of those departments which are less than 40

vii)Find the details of all doctors whose salary is greater than the average salary of all doctors. viii)Display the name and age of doctors who work in departments that offer OPD on 'TTS'. ix)Display the doctor names, department, and salary for all doctors whose name ends with the letter 'a'. x) Find the maximum and minimum salary for each department. xi) Display the department name that charges the highest OPD fee. 




Wednesday, 29 July 2026

RAILWAY DATABASE


CREATE DATABASE railway;

USE railway;

 CREATE TABLE train (

    train_number VARCHAR(10) PRIMARY KEY, -- Indian train numbers are 5-digit codes

    train_name VARCHAR(100) NOT NULL,

    origin VARCHAR(50) NOT NULL,

    destination VARCHAR(50) NOT NULL,

    fare DECIMAL(7,2) NOT NULL, 

    seats_available INT NOT NULL

);

INSERT INTO train VALUES

('22436', 'Vande Bharat ', 'Delhi', 'Varnas',  1750, 45),

('12952', 'Rajdhani', 'Hyder', 'Mumbai', 2400, 18),

('12002', 'Shatabdi ', 'Delhi', 'Chennai', 1165, 85),

('12626', 'Kerala Exp', 'Mumbai', 'Trivand',  810, 120);



Monday, 27 July 2026

 String Functions

Q1. Display each pet's name in UPPERCASE and its species in lowercase.

Q2. Format the output so it reads like a sentence: "[pet name] is owned by [owner]".

Q3. Create a short code for each pet consisting of the first 3 letters of its species in uppercase followed by the last 3 letters of pet's name.

Q4. Find the length of each pet's name and display only those pets whose names have more than 5 characters.

Q6. Display the event remarks after removing any leading or trailing spaces.


Numeric Functions

Q7. Display the rounded fee to 2 decimal places and truncated fee to 2 decimal places ,if the fee is Rs 125.6789

Q8. Assign pets into 2 alternate checkup groups(group1 or group2) based on whether their birth year is even or odd (using MOD).

Q9. Display the square root of each pet's birth year rounded to 2 decimal places.

Q10. Check the sign of the difference between 1995 and pet's birth year using SIGN().

Q11. Round the birth year of all pets to the nearest tens place (e.g., 1993 becomes 1990).

Q12. Calculate 2 raised to the power of the length of the pet's name .


Date & Time Functions

Q13. Select the current date, current time, and current timestamp in a single query.

Q14. Extract the birth year, birth month, and birth day for all pets.

Q15. Find all pets that were born in the month of May (Month 5).

Q16. Find all events that occurred in or after the year 1995.

Q17. Extract only the date part from a NOW() system call.

Q18. Demonstrate the difference between NOW() and SYSDATE() by running them with a delay using SLEEP().


Sunday, 19 July 2026

grade 12 - practical 14 - 20 july 2026

 WAP to create the below tables where student refers to stream : 


STUDENT:



STREAM:




a) Alter the table to include a column named sex char(1) after lname.

b)Update the sex to 'm' for admission numbers 1001,1003,1005,1007,1010 and 'f' for the others

c)Display the admno , fullname(fname + lname ) and mobile no.

d)Display stream id and stream wise total fee collected

e)Count the number of students from each area

f)Increase the fees of all students  by 10%

g)Display the unique areas from the student table

h)Display details of those students who's name starts with 'R' or last name starts with 'S'

i) Display admno,fullname(fname+lname) , class(class+sec) of all the students that belong to xii a and xii b.

j)Display the count of male students and female students

k)Display the admno, fname and stream name of the student

l) Display the count of male students and female students in class xii

m) Display the fees of students in every class/section


Thursday, 16 July 2026

TERM I-REVISION WORKSHEET-2026-27



1. Answer the below ASSERTION(A) AND REASONING(R) based questions. Mark the correct choice as :

(i)Both A and R are true and R is the correct explanation for A.

(ii)Both A and R are true and R is not the correct explanation for R.

(iii)A is true but R is false.

(iv)A is false but R is true.


a) (A): The close() method is used to close the file.

(R): While closing a file, the system frees up all the resources like processor and memory allocated to it.

b)(A): To preserve the data for future purpose in Python is called pickling.

(R): Unpickling is a technique that returns the byte stream produced by pickling back into Python objects.

c) A): CSV stands for Comma separated values.

(R): CSV files are common file format for transferring and storing data

d)(A): Access mode ‘a’ opens the file for appending.

(R): So it writes text only in the end of the file, but if we use seek(0), it will change the file pointer the beginning of the file and write the text there.

e) (A): DDL commands are used to manipulate data in the table.

(R): INSERT and UPDATE are examples of DDL commands.


2) Below two questions are based on sample.txt which contains :

Apple

Banana

Cherry

Dragonfruit

Predict the output of :

i) f = open("sample.txt", "r")

f.read()

print(f.read())

f.close()

ii)  f = open("sample.txt", "r")

print(f.readline(2))

print(f.readline())

print(f.read())

f.close()


3. A table STUDENT has 6 rows and 4 columns.What is the degree and cardinality of the table?


4) def update_data(X, Y):

X.append(30)

Y = Y + [30]

print(X, Y, sep="*")

List1 = [10, 20]

Li st2 = [10, 20]

update_data(List1, List2)

print(List1, List2, sep="#")


5)Observe the following Python function definition and call:

def Assign(P, Q, R=100):

    print(P, Q, R)

Assign(10, 20, P=30)

What will be the outcome of executing this code?


6)Differentiate between :



7) a) Write a function addrec() in Python to add 1 new record at the end of the binary file “Student.dat”, assuming that the binary file contains the following structure : {Roll:<int>,sname:<str>,score:<int>}

b) Increase the score of all the students who scored between 30-34 to 35.

c) Search for a certain roll no , and display the score

d) Display all the records


8) Define a function remove_newline() which will remove new line from sample.txt:


9) Write python code that works on text files :

a) Write a function entry() that accepts10 lines on the uses of python and writes it into data.txt.

b) Write a function summary() that reads data.txt and:

>Counts the number of words that start with ‘re’

>Displays the lines that end with tion (remove the fullstop or question mark before you check)

>Prints all lines that contain the word “python”

>Replace every occurrence of red by RED.


10) A binary file (weather.dat) which contains each record as a list, as given : [“date”,lowest temperature,highest temperature] eg. [“26-08-2023”,30.0,40.0]

a) Update all the records to contain a 4th field – average temperature.

b) Search for a particular date and display its average temperature, If the record is not found, display ‘Record Not Found’.

c) Display all the records and the lowest and highest temperatures recorded


11) The following is a snapshot of customer.csv.



a) Accept records until the user wants to stop.

b) Display all the records in a tabular format. Also the total amount of sales.

c) Search for a serial number and display the corresponding Amount

d) Update all those from Bangalore to Bengaluru.

e) Accept a name delete a row from the above csv file if the record exists.


12. Your parent wishes to maintain their monthly expenses. Write the following python functions:

a) accept () to prompt the user to enter expense details and store them into the file ‘Expense_July.csv’ with appropriate headers :



b) total() to display all the records from Expense_July.csv and also print the total expense for the month.

c) update() to change the school fees to 8000



13)Given the list:

sales = [["Tom", 12000], ["Ava", 8000], ["Kia", 15000], ["Max", 9000]]

Write Python code to:

a) Push the names of salespersons into a stack only if their sales are above 10,000.

b) Display the names from the stack without deleting the elements.

c) Pop the topmost element from the stack


14) Write a SQL query to CREATE a table Faculty with columns:

Fid (INT, PRIMARY KEY)

Name (VARCHAR(30))

Department (VARCHAR(20))

Salary (DECIMAL(8,2))

a) A a new column Email (VARCHAR(40))

b) Change Department column to DeptName

c) Change Name column data type to VARCHAR(20)

d) Remove the column Salary

e)Remove the primary key

f)Make Fid,Name as the new primary key

g)Why is it important to define constraints in a table?


15) Identify and correct the errors in the following SQL statements:

a) CREATE TABLE Emp (ID int, Name varchar, Salary float);

b) ALTER TABLE Emp DROP Salary WHERE ID=3;

c) ALTER Emp RENAME COLUMN Name TO EmpName;


16) Answer the questions that follow the table given below:



a) What is the full form of RDBMS? Give one advantage of RDBMS of CSV file

b) What is the cardinality of the above table ? What is the degree of the above table ?

c) Which is/are the alternate/primary/candidate key/keys in the above table?

d) Identify the below commands as either DDL, or DML. :

INSERT, ALTER, DROP, CREATE, UPDATE, DELETE


17) Answer briefly :

a)referential integrity.

b)primary key and give one example.

c)secondary key with example

d)various constraints

e)what is the various referential actions -set null, no action , cascade and restrict?

f) one difference between CSV files and tables in MySQL.


18) What does cascade do in the below context ?

CREATE TABLE EMPLOYEE (

EmpID INT PRIMARY KEY,

EmpName VARCHAR(30),

DeptID INT,

FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID) ON DELETE CASCADE

);