0% found this document useful (0 votes)
74 views71 pages

CS Holiday Homework

Uploaded by

Vansh Singhai
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)
74 views71 pages

CS Holiday Homework

Uploaded by

Vansh Singhai
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/ 71

BHARTI PUBLIC

SCHOOL
COMPUTER SCIENCE
PRACTICAL FILE
Subject code-083
CLASS – 12A
ROLL. NO-

SUBMITTED BY: Ayush Aithani


SUBMITTED TO: Mrs. Priyanka Rastogi
INDEX
S.NO DATE QUESTION
PG NO.
1) 13-10-23 Write SQL commands for the following on the basis of the given table
SPORTS 1-3

2) 13-10-23 Write SQL commands for the following on the basis of given table CLUB
4-6

3) 13-10-23 Write SQL commands for the following on the basis of the given table
STUDENT 7-9

4) 13-10-23 Give the output of the following SQL commands with respect to table
STUDENT 10-12

in the previous question

5) 13-10-23 Write SQL queries based on the table PASSENGER and FLIGHT given
below 13-15

6) 13-10-23 Write code to connect to a MySQL database namely School and then
fetch all those 16-17

records from table Student where grade is ‘A’

7) 21-10-23 Bharti Public School is managing student data in the Student table in
School Database. 18-21

Write a Python code that connects to a database school and retrieves all
records and

displays the total number of students.

8) 21-10-23 Create a database TestDb. Create a table Employee with fields


first_name, last_name, age, 22-24

sex, income. Insert below two records in it:

9) 21-10-23 Write a program with reference to the above table “Employee” to


increase the salary of 25-27

employees, whose name is Manoj Kumar by Rs 3000.

10) 02-11-23 WAP to read a text file line by line and display each word separated by a
# 28-30

11) 02-11-23 WAP to read a text file and display the number of
vowels/consonants/uppercase/lowercase 31-32

characters in the file.

12) 02-11-23 WAP to remove all the lines that contain the character 'a' in a file and write
it to another file 33-34

13) 02-11-23 Create a binary file with name and roll number. Search for a given roll
number and display 35-36
the name, if not found display appropriate message

14) 02-11-23 Create a binary file with roll number, name and marks. Input a roll number
and update the 37-38

marks.

15) 02-11-23 Write a random number generator program that generates random
numbers between 1 and 6 39-40

(simulates a dice).

16) 02-11-23 Write a program to accept values from a user in a tuple. Add a tuple to it
and display its 41-42

elements one by one. Also display its maximum and minimum value.

17) 02-11-23 Create a CSV file by entering user-id and password, read and search the
password for given 43-44

user id

18) 09-11-23 Write a program to create a dictionary from a string. Note: Track the count of the
letters from the 45-46

string. Sample string : 'w3resource'. Expected output: {'w': 1, '3': 1, 'r': 2, 'e': 2, 's':
1, 'o': 1, 'u': 1, 'c': 1}

19) 09-11-23 Write a function, lenWords(STRING), that takes a string as an argument and
returns a tuple containing 47-48

the length of each word of a string. For example, if the string is "Come let us have
some fun", the tuple

will have (4, 3, 2, 4, 4, 3).

20) 09-11-23 Write a function in Python to read a text file, Alpha.txt and display those lines
which begin with the word 49-50

‘You’.

21) 09-11-23 Write a function, vowelCount() in Python that counts and displays the number of
vowels in the text file 51-52

named Poem.txt.

22) 09-11-23 Write a function listchange(Arr) in Python , which accepts a list of numbers and
replace each even 53-54

number by value 10 and multiply odd number by 5. Sample input data of the list is:
a= [10,20,23,45],

listchange(a), Output: [10,10,115,225].

23) 09-11-23 A dictionary student contains rollno and marks of students. Two empty lists
stack_roll and stack_mark 55-56

will be used as stack. Two functions Push_student() and Pop_student() are defined
and perform the

following operation: (i) Push_student(): It reads dictionary student and adds keys
into stack_roll and

stack_marks for all students who secured more than 60 marks. (ii) (ii)
Pop_student(): It removes last

rollno and marks from both list and prints “underflow” if there is nothing to
remove.

24) 09-11-23 A list, NList contains the following record as list elements: [City, Country, distance
from Delhi] Each 57-61
of these records are nested together to form a nested list. Write the following user
defined functions in

Python to perform the specified operations on the stack named travel. (i)
Push_element(NList): It takes

the nested list as an argument and pushes a list object containing the name of the
city and country, which

are not in India and distance is less than 3500 km from Delhi. (ii) Pop_element(): It
pops the objects from

the stack and displays them. Also, the function should display “Stack Empty” when
there are no elements

in the stack.
i)

ii)

iii)
Q1. Write SQL commands for the
following on the basis of the given table
SPORTS:

StudentN Class Name Game Grade SUPW Grade


o 1 2

10 7 Sameer Cricket B Photography A

11 8 Sujit Tennis A Gardening C

12 7 Kamal Swimming B Photography B

13 7 Veena Tennis C Cooking A

14 9 Archana Basketball A Literature A

15 10 Arpit Cricket A Gardening C

i)Display the details of students who are in grade 7.


ii) Display the names of students who are getting grade
‘C’ in either GAME or SUPW.

iii) Display the different games offered in school

iv)

v)
iv) Display the SUPW taken up by the students, whose
name starts with ‘A’.

v) Modify the Game of Sujit from Tennis to Basketball.


i)

ii)
iii)

Q2. Write SQL commands for the


following on the basis of given table
CLUB:

Coach_id CoachNa Age Sports Datofap Pay Sex


me p

1 Kukreja 35 karate 27/03/19 1000 M


96

2 Ravina 34 Karate 20/01/19 1200 F


98

3 Karan 36 Squash 19/02/19 2000 M


98

4 Tarun 34 Basketbal 12/01/19 1500 M


l 98

5 Zubin 33 Swimmin 20/02/19 750 M


g 98

6 Ankita 34 Squash 01/01/19 800 F


98

7 Kush 36 Karate 14/01/19 1700 M


98

(i)To show all information about the swimming coaches


in the club.

(ii) To list the names of all coaches with their date of


appointment( Datofapp) in descending order.

(iii) To display a report, showing coachname, pay age,


bonus (15 % of pay) for all coaches.

iv)
v)
(iv) To rename attribute ‘pay’ to ‘salary’.

(v) To delete the record of Karan.


i)

ii)

iii)
Q3. Write SQL commands for the
following on the basis of the given table
STUDENT.

ID Name Stipend Stream Avgmark Grade Class

A1 Karan 400.00 Medical 78.5 B 12B

B1 Divakar 300.00 Commerc 89.2 A 12A


e

C1 Divya 350.00 Humaniti 68.6 C 12C


es

D5 Arun 500.00 Medical 73.1 B 12B

E2 Sahiba 400.00 Commerc 90.6 A 12A


e

(i)Select all the non medical stream students from the


student table.

(ii) List the name of those students who are in class 12


sorted by stipend.

(iii) Display a report listing name, stipend, stream and


amount of stipend received in a year assuming that the
stipend is paid every month.
iv)

v)
iv) Count the number of students getting grade B and C.

v) Select max(Name) from student;


i)

ii)

iii)
Q4. Give the output of the following SQL
commands with respect to table STUDENT in
the previous question.

(i)Select min(Avgmark) from student where Avgmark


<75;

(ii) Select Sum(Stipend) from Student where Grade = ‘B’ ;

(iii) Select avg (Stipend) from student where class=’12A’;


iv)

v)
(iv) Select count(Distinct(stream)) from student;

(v) Select max(Name) from student;


i)

ii)

iii)
Q5 Write SQL queries based on the table PASSENGER and FLIGHT given
below:
Table: PASSENGER

PNO NAME GENDER FNO

1001 Suresh MALE F101

1002 Anita FEMALE F104

1003 Harjas MALE F102

Table: FLIGHT

FNO START END F_DATE FARE

F101 MUMBAI CHENNAI 2021-12-25 4500

F102 MUMBAI BENGALURU 2021-11-20 4000


F103 DELHI CHENNAI 2021-12-10 5500

F104 KOLKATA MUMBAI 2021-12-20 4500

(i)Write a query to change the fare to 6000 of the flight whose


FNO is F104.

(ii) Write a query to display the total number of MALE and FEMALE
Passengers.

(iii) Write a query to display the NAME , corresponding FARE and


F_Date of all Passengers who have a flight to START from Delhi.

iv)

v)
(iv) Write a query to delete the records of flights which end at
Mumbai.

(v) Display the Flight date and fare of Nita.


PYTHON
MYSQL
CONNECTIVI
TY
PROGRAMS

OUTPUT:
Q6 Write code to connect to a MySQL database namely School
and then fetch all those records from table Student where grade
is ‘A’.
Output:
Q7. Bharti Public School is managing student data in the Student
table in School Database. Write a Python code that connects to a
database school and retrieves all records and displays the total
number of students.
OUTPUT:

Q8 Create a database TestDb. Create a table Employee


with fields first_name, last_name, age, sex, income. Insert
below two records in it:
Manoj , Kumar ,30, M, 25000
Karan, Verma, 32, M, 27000
OUTPUT:

Q9. Write a program with reference to the above table


“Employee” to increase the salary of employees, whose
name is Manoj Kumar by Rs 3000.
QUESTIONS
RELATED TO
DATA FILE
HANDLING
OUTPUT:
Q10 WAP to read a text file line by line and display each
word separated by a #.
OUTPUT:
Q11 WAP to read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the
file.
OUTPUT:
Q12 WAP to remove all the lines that contain the
character 'a' in a file and write it to another file.
OUTPUT:
Q13 Create a binary file with name and roll number.
Search for a given roll number and display the name, if
not found display appropriate message.
OUTPUT:
Q14 Create a binary file with roll number, name and marks. Input
a roll number and update the marks.
OUTPUT:
Q15 Write a random number generator program that generates random
numbers between 1 and 6 (simulates a dice).
OUTPUT:
Q16 Write a program to accept values from a user in a tuple. Add
a tuple to it and display its elements one by one. Also display its
maximum and minimum value.
OUTPUT:
Q17 Create a CSV file by entering user-id and password, read and
search the password for given user id.
OUTPUT:
Q18 Write a program to create a dictionary from a string. Note:
Track the count of the letters from the string. Sample string :
'w3resource'. Expected output: {'w': 1, '3': 1, 'r': 2, 'e': 2, 's': 1,
'o': 1, 'u': 1, 'c': 1}
OUTPUT:
Q19 Write a function, lenWords(STRING), that takes a string as an
argument and returns a tuple containing the length of each word
of a string. For example, if the string is "Come let us have some
fun", the tuple will have (4, 3, 2, 4, 4, 3).
OUTPUT:
Q20 Write a function in Python to read a text file, Alpha.txt and
display those lines which begin with the word ‘You’.
OUTPUT:
Q21 Write a function, vowelCount() in Python that counts and
displays the number of vowels in the text file named Poem.txt.
OUTPUT:
Q22 Write a function listchange(Arr) in Python , which accepts a
list of numbers and replace each even number by value 10 and
multiply odd number by 5. Sample input data of the list is: a=
[10,20,23,45], listchange(a), Output: [10,10,115,225]
OUTPUT:
Q23 A dictionary student contains rollno and marks of students.
Two empty lists stack_roll and stack_mark will be used as stack.
Two functions Push_student() and Pop_student() are defined and
perform the following operation: (i) Push_student(): It reads
dictionary student and adds keys into stack_roll and stack_marks
for all students who secured more than 60 marks. (ii) (ii)
Pop_student(): It removes last rollno and marks from both list and
prints “underflow” if there is nothing to remove.
OUTPUT:

\
Q24 A list, NList contains the following record as list elements:
[City, Country, distance from Delhi] Each of these records are
nested together to form a nested list. Write the following user
defined functions in Python to perform the specified operations on
the stack named travel. (i) Push_element(NList): It takes the
nested list as an argument and pushes a list object containing the
name of the city and country, which are not in India and distance
is less than 3500 km from Delhi. (ii) Pop_element(): It pops the
objects from the stack and displays them. Also, the function
should display “Stack Empty” when there are no elements in the
stack.

You might also like