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

CS_practical_qns

Uploaded by

buffybenita
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

CS_practical_qns

Uploaded by

buffybenita
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q.No.

1. i) Write a function WriteStudent() to write the Records of Students (admno, name, fee)
in a CSV file name “stud.csv”.

ii) Write a function Display() to display those records from a CSV file where fee is
greater than 2500

2. Consider the following tables Stationary and Consumer. Write SQL commands for the
statement (i) to (iv).
Table : Stationary

S_ID StationaryNam Company Price


e
DP01 Dot Pen ABC 10
PL02 Pecil XYZ 6
ER05 Eraser XYZ 7
PL01 Pencil CAM 5
GP02 Gel Pen ABC 15

Table : Consumer

C_ID Consumer Name Address S_ID


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

(i) To display the details of those consumers whose Address is Delhi.

(ii) To display the details of Stationary whose Price is in the range of 8 to 15. (Both
Value included)

(iii) To display the ConsumerName, Address from Table Consumer, and Company and
Price from tableStationary, with their corresponding matching S_ID.

(iv) To increase the Price of all stationary by 2


Q.No. 2

1. Create a python program named Count.py to read a text file – Mytext.txt and
display the number of upper case, lower case, digits and special
characters(including space).

2. Consider the following tables FACULTY and COURSES. Write SQL commands for the
statements (i) to (iv)

Table : FACULTY

F_I Fname Lname Hire_date Salary


D
102 Amit Mishra 1998-10-12 12000
103 Nitin Vyas 1994-12-24 8000
104 Rakshit Soni 2001-05-18 14000
105 Rashmi Malhotra 2004-09-11 11000
106 Sulekha Srivastava 2006-06-05 10000

Table : COURSES

C_ID F_ID Cname Fees


C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer 20000
Network

i) To display details of those Faculties whose salary is greater than 12000.

ii) To display the details of courses whose fees is in the range of 15000 to 50000
(both values included).

iii) To increase the fees of all courses by 500 of “System Design” Course.

iv) To display details of those courses which are taught by ‘Sulekha’ in


descending order of courses.
Q.No. 3

1. Write a python program using list to implement stack data structure and perform the
following operations:
a. Push()
b. Pop()
c. Display()
d. Peek()

Table : TRAINS

TNO TNAME START END


1109 Ahimsa Express Pune Junction Ahmedabad Junction
6
1201 Ajmer Shatabdi New Delhi Ajmer Junction
5
1651 Pune Hbj Special Pune Junction Habibganj
1300 Amritsar Mail Howrah Junction Amritsar Junction
5
1200 Bhopal Shatabdi New Delhi Habibganj
2

Table : PASSENGERS

PNR TNO PNAME GENDER AGE


P00 13005 R N AGARWAL MALE 45
1
P00 12015 P TIWARY MALE 28
2
P00 12015 S TIWARY FEMALE 22
3
P00 12030 S K SAXENA FEMALE 42
4
P00 12030 S SAXENA MALE 35
5

2.Write SQL queries for (i) to (iv)

(i) To display details of all Trains which Start from New Delhi.

(ii) To display the PNR, PNAME, GENDER and AGE of all Passengers whose AGE is
below 50.

(iii) To display total number of MALE and FEMALE Passengers.

(iv) To display details of all Passengers travelling in Trains whose TNO is 12015.
Q.No. 4

1. Write a Python Program to read a text file line by line and to display each word in the
file separated by “#”.

2. Write SQL queries for (i) to (iv)

Table : TRAINER

TID TNAME CITY HIREDATE SALARY


101 SUANINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHADIGARG 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000

Table : COURSE

CID CNAM FEES STARTDATE TID


E
C201 AGDCA 12000 2018-07-02 101
C202 ADCA 15000 2018-07-15 103
C203 DCA 10000 2018-10-01 102
C204 DDTP 9000 2018-09-15 104
C205 DHN 20000 2018-01-18 101

(i) Display the Trainer Name, City & Salary in descending order of their Hiredate.

(ii) To display the TNAME and CITY of Trainer who joined the Institute in the month
of December 2001.

(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER


and COURSE of all those courses whose FEES is less than or equal to 10000.

(iv) To display number of Trainers from each city.


Q.No. 5

1. Implement two functions in python to create and access binary file “student.dat”.
i) Addbin() –to write a dictionary that holds students roll no and mark as key
value pairs into a binary file “student.dat”.
ii) Dispbin() – to display the roll numbers and marks of students who secured
more than 70 marks.

2. Write the queries for the i) to iv) based on the given tables.

Table : EmpSalary

Empi Salary Benefits Designation


d
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk

Table : Employees

Empi FirstName LastNam Address City


d e
010 Ravi Kumar Raj Nagar GZB
105 Harry Waltor Gandhi Nagar GZB
152 Sam Toes 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24Friends Street New York

i) To show firstname, lastname, address and city of all employees living in paris

ii) To display the content of Employees table in descending order of Firstname.

iii) To display the firstname, lastname and totalsalary of all managers from the tables
Employee and empsalary, where totalsalary is calculated as salary+benefits.

iv) To display the maximum salary among managers and clerks from the table
Empsalary.

You might also like