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

Pratical Questions

The document outlines various programming tasks in Python and SQL, including reading and manipulating files, querying databases, and performing operations on tables. It specifies tasks such as filtering lines from a text file, replacing characters in a file, and executing SQL queries on multiple tables related to stationery, teachers, and school administration. Additionally, it includes operations on an employee table, such as inserting records and updating salaries.

Uploaded by

Manan Verma
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)
4 views

Pratical Questions

The document outlines various programming tasks in Python and SQL, including reading and manipulating files, querying databases, and performing operations on tables. It specifies tasks such as filtering lines from a text file, replacing characters in a file, and executing SQL queries on multiple tables related to stationery, teachers, and school administration. Additionally, it includes operations on an employee table, such as inserting records and updating salaries.

Uploaded by

Manan Verma
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/ 3

1. (A) Write a program in python to read file “data.

txt” and display only


those lines whose length is more than 40 characters.
2. (B) Write a program in python to replace all the ‘a’ by ‘@’ in a file
“data.txt”.
3. Write SQL queries on the basis of following tables.
Table: STATIONERY
S_ID STATIONERY COMPANY PRICE STOCKDATE
NAME
Dp01 Dot Pen ABC 10 2011-03-31
PL02 Pencil XYZ 6 2010-01-01
ER05 Eraser XYZ 7 2010-02-14
PL01 Pencil CAM 5 2009-01-09
G02 Gel Pen ABC 15 2009-03-19

C_ID ConsumerName Address P_ID


01 Good Leaner Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Write & Draw Delhi PL02
16 Motivation Bengaluru PL01

(i) To display details of that stationery item whose Company is


XYZ and price is below 10.
(ii) To Display consumername, Address from the table consumer
and company and price from stationery table, with their
corresponding S_ID.
(iii) To increase the price of all the stationery items in stationery
table by rs. 2
(iv) To display the details of all stationery items in the stationery
table in descending order of stockdate.
4 . Consider a CSV file “data.csv” which stores the record of “students” in
the form of list containing Adm_no, Name,Class, Section, Marks. Do the
following task in a file.
(i) Write a function addrec() to add a record in a record in a file.
(ii) Write a function disp() to display all the records from the file.
(iii) Write a function specific_disp(adm_no) which takes admission
number as argument and display its details.

5. Write SQL queries on the basis of following tables.


Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
T01 Aman 34 Computer 2017-01-17 12000 M
Science
T02 Suman 31 History 2008-03-24 20000 F
T03 Sandeep 32 Mathemaric 2016-12-12 30000 M
s
T04 Moumita 35 History 2015-07-01 40000 F
T05 Raman 42 Computer 2007-09-05 25000 M
Science

(i) To list the names of female teachers who are in mathematics


department.
(ii) To display teacher’s name whose name is starts with ‘S’ and salary is
more than 20000.
(iii) To display name,bonus for each teacher where bonus is 10% of salary.
(iv)To delete column Gender from the table.
6. Write SQL queries on the basis of following tables.
TABLE: SCHOOL
CODE TEACHERNAM SUBJECT DOJ PERODS EXPERIENCE
E
1001 RAVI SHANKAR ENGLISH 12/03/2000 24 10
1009 PRIYA RAI PHYSICS 03/09/1998 26 12
1203 LISA ANAND ENGLISH 09/04/2000 27 5
1045 YASHRAJ MATHS 24/08/2000 24 15
1123 GANAN PHYSICS 16/07/1999 28 3

TABLE: ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 MALE HOD
1045 MALE SENIOR TEACHER

1. Display All coordinators with their name and gender.


2. Display number of subjects teach in a school.
3. Display details of those teachers who teach subject English and
experience is more than 5 years.
4. Display date of join of all the teachers.

7. Consider the information stored in the table EMP and perform the
following operation on it:
EMPNO ENAME DEPT SALRY
1 Rajesh IT 60000
2 Anusha History 65000
3 Kinshuk Marketing 70000
4 Abhay Fashion Studies 45000

(i) Enter above records in the table with the use of python program.
(ii) Perform following queries with use of python program.
(a) Display all the records in python which is stored in EMP table.
(b) Display all records in python whose salary >50000.
(c) Update salary for all the employees by 10% .

You might also like