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

updated QUESTION AND ANSWER

The document contains a series of programming tasks divided into sets A to E, focusing on Python programming and SQL queries. Each set includes specific tasks such as reading files, manipulating CSV data, and executing SQL queries on various tables like Student, Employee, and Hospital. The tasks range from displaying data to updating records and require the implementation of user-defined functions.

Uploaded by

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

updated QUESTION AND ANSWER

The document contains a series of programming tasks divided into sets A to E, focusing on Python programming and SQL queries. Each set includes specific tasks such as reading files, manipulating CSV data, and executing SQL queries on various tables like Student, Employee, and Hospital. The tasks range from displaying data to updating records and require the implementation of user-defined functions.

Uploaded by

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

SET A

1. Write a python program to read a text file line by line and display each word
separated by '#'. (3)

2. Write a program in python that defines and calls the following user defined
functions:
The structure of peripheral.csv is: [p_id, p_name, price]
Add_device( ) : to accept a record from the user and add it to a csv file,
peripheral.csv
Count_device( ) : to count and display number of peripheral devices whose price
is less than 1000.
(5)
3. Write SQL queries to do the following: Table:Student (4)

(a) Display name of female students in Hindi department


SELECT name
FROM Student
WHERE gender = 'Female' AND department = 'Hindi';
(b) Display name of the students whose ages are between 18 to 20.
SELECT name
FROM Student
WHERE age BETWEEN 18 AND 20;
(c) Display the name of the students whose name is starting with 'a'
SELECT name
FROM Student
WHERE name LIKE 'a%';
(d) Display name of those students whose name have second alphabet 'n' in
their names.
SELECT name
FROM Student
WHERE name LIKE '_n%';
SET B
1. Creating a python program to read a text file and display the number of vowels/
consonants/lower case/ upper case characters. (3)

2. Write a python program to create a binary file with roll number and name. Search
for a given roll number and display the name, if not found display appropriate
message.
(5)
3. Write SQL Queries for the following Queries: Table: Employee (4)
EmpNo EmpName Dept Salary Designation
150 Arnav Marketing 45000 Executive
134 Bharathi Sales 35000 Executive
167 Chandru Marketing 38500 Asst. Manager
195 Dithya Null 37000 Manager
208 Feroz Sales 60000 Manager

a) Display the details of Employees in ascending order of EmpNo.


SELECT *
FROM Employee
ORDER BY EmpNo ASC;
b) Display all the department names without repetition.
SELECT DISTINCT Dept
FROM Employee;
c) Display the name of the employee whose salary between 30000 and 45000 in
the table.
SELECT EmpName
FROM Employee
WHERE Salary BETWEEN 30000 AND 45000;
d) Display the name of the employee for whom Department is not assigned.
SELECT EmpName
FROM Employee
WHERE Dept IS NULL;
SET C
1. Write a python program to display short words (less than 4 ) from a text file. (3)

2. Write a python program to get student data (rollno, name, marks) from user and
write onto a binary file. The program should be able to get data from the user and
write onto the file as long as the user wants. (5)
3. Write SQL Queries for the following Queries: Table: Employee (4)
PROD_ID PROD_NAME PRICE COMPANY TYPE
P001 Mouse 200 LOGITECH INPUT
P002 Laser Printer 4000 CANON OUTPUT
P003 Keyboard 500 LOGITECH INPUT
P004 Joystick 1000 IBALL INPUT
P005 Speaker 1200 CREATIVE OUTPUT

a) Display the details of Maximum and Minimum price of products.


SELECT max(PRICE), min(PRICE)
FROM Employee;
b) Display the product details price in the range of 400 to 1200
SELECT PROD_ID, PROD_NAME, PRICE, COMPANY, TYPE
FROM Employee
WHERE PRICE BETWEEN 400 AND 1200;
c) Display the total price of the product each company wise.
SELECT COMPANY, SUM(PRICE) AS Total_Price
FROM Employee
GROUP BY COMPANY;
d) Display the product details in descending order of Price
SELECT PROD_ID, PROD_NAME, PRICE, COMPANY, TYPE
FROM Employee
ORDER BY PRICE DESC;

SET D
1. Write a python program to display lines that starts with ‘A’ from a text file. (3)
2. Write a program in Python that defines and calls the following user defined
functions: The structure of 'courier.csv' is: cid, s_name, Source, destination
(i) COURIER_ADD() : It takes the values from the user and adds the details to a csv
file 'courier.csv'.
(ii) COURIER_SEARCH() : Takes the destination as the input and displays all the
courier records going to that destination. (5)

3. Write sql queries for the following table. Table: Student (4)

ROLLNO NAME CLASS DOB GENDER CITY MARKS


1 Nanda X 1995-06-06 M Agra 551
2 Saurabh XII 1993-05-07 M Mumbai 462
3 Sonal XI 1994-05-06 F Delhi 400
4 Trisla XII 1995-08-08 F Mumbai 450
5 Hari XII 1995-10-08 M Chennai 500
6 Neha X 1995-12-08 F Bangalore 377
7 Nishanth XI 1995-06-12 M Delhi 489
i) To display name, class who have scored more than 450 marks, class
wise
SELECT NAME, CLASS
FROM Student
WHERE MARKS > 450
ORDER BY CLASS;
ii) To increase the marks of student by 5 whose city is Delhi
UPDATE Student
SET MARKS = MARKS + 5
WHERE CITY = 'Delhi';
iii) To Delete the record of students whose mark is less than 400
DELETE FROM Student
WHERE MARKS < 400;
iv) To display the name, class, marks of students whose name starting
with N
SELECT NAME, CLASS, MARKS
FROM Student
WHERE NAME LIKE 'N%';

SET E
1. Creating a python program to read a text file and display the number of vowels/
consonants/lower case/ upper case characters. (3)

2. Write a program in python that defines and calls the following user defined
functions: The structure of peripheral.csv is: [p_id, p_name, price]
Add_device( ) : to accept a record from the user and add it to a csv file,
peripheral.csv
Count_device( ) : to count and display number of peripheral devices whose price
is less than 1000. (5)

3. Write sql queries for the following table. TABLE : HOSIPTAL (4)
NO NAME AGE DEPARTMENT DOA CHARGES SEX
1 SANDEEP 65 SURGERY 23/02/98 300 M
2 RAVINA 24 ORTHOPEDIC 20/01/98 200 F
3 KARAN 45 ORTHOPEDIC 19/02/98 200 M
4 TARUN 12 SURGERY 01/04/98 300 M
5 ZUBIN 36 ENT 12/02/98 250 M
6 KETAKI 16 ENT 24/02/98 300 F
7 ANKITA 29 CARDIOLOGY 20/02/98 800 F

i) To List all the information of patients of ENT department.


SELECT *
FROM HOSPITAL
WHERE DEPARTMENT = 'ENT';
ii) To list the names of all patients with date of admission in descending
order
SELECT NAME, DOA
FROM HOSPITAL
ORDER BY DOA DESC;
iii) To display the total number of patients gender wise
SELECT SEX, COUNT(*) AS Total_Patients
FROM HOSPITAL
GROUP BY SEX;
iv) To add new column named contact number of integer data type
ALTER TABLE HOSPITAL
ADD CONTACT_NUMBER INT;

You might also like