Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

CENTRAL BOARD OF SECONDARY EDUCATION

Computer Science (083)


Practical File

Submitted To: Submitted By:


Mr Abhishek Bhardwaj Cdt. Harshit choudhary
TGT- Computer Science Sch.No. : 5597
Class : XII-A
ACKNOWLEDGEMENT

I wish to express my deep sense of gratitude and indebtedness


to our learned teacher Mr Abhishek Bhardwaj, TGT- Computer
Science, Sainik School Chittorgarh for his invaluable help,
advice and guidance in the preparation of this practical file.

I am also greatly indebted to our Principal Col S Dhar, Offg


Vice Principal Maj Deepak Malik and school authorities for
providing me with the facilities and requisite laboratory
conditions for making this practical file.

I also extend my thanks to my parents, teachers, my


classmates and friends who helped me to complete this
practical file successfully.

Cdt. Harshit choudhary


CERTIFICATE

This is to certify that Cdt.Harshit choudhary student of Class


XII, Sainik School Chittorgarh has completed the PRACTICAL
FILE during the academic year 2022-23 towards partial
fulfillment of credit for the Computer Science (083) practical
evaluation of CBSE and submitted satisfactory report, as
compiled in the following pages, under my supervision.

Internal Examiner External Examiner


Signature Signature
INDEX

Page
Ser Objective Signature
No
(i) Write a Python program to implement a stack using a list 1
data structure.
(ii) Create a student table with the student id, name, and marks 3
as attributes, where the student id is the primary key.
(iii) Insert the details of new students in the student table. 4
(iv) Delete the details of a student in the student table. 5
(v) Use the select command to get the details of the students 6
with marks more than 80.
(vi) Find the min, max, sum, and average of the marks in student 7
marks table.
(vii) Write a SQL query to display the marks without decimal 8
places, display the remainder after diving marks by 3 and
display the square of marks.
(viii) Write a SQL query to display names into capital letters, small 9
letters, display first 3 letters of name, display last 3 letters of
name, display the position the letter A in name.
(ix) Display today's date. Also display the date after 10 days 10
from current date.
(x) Display dayname, monthname, day, dayname, day of month, 11
day of year for today's date.
(xi) Write a Python program to check Successful connection with 12
MySQL.
(xii) Write a Python program to insert data into student table 13
created in MySQL.
(xiii) Write a Python program to update data into student table 15
created in MySQL.
(xiv) Write a Python program to fetch all data from student table 17
created in MySQL.
(xv) Write a Program in Python to Read a text file’s first 30 bytes 20
and printing it.
(xvi) Write a Program in Python to display the size of a text file 21
after removing EOL (/n) characters, leading and trailing white
spaces and blank lines.
(xvii) Write a Program in Python to create a text file with some 22
names separated by newline characters without using write()
function.
(xviii) Write a Program in Python to Read, Write (Multiple Records) 23
& Search into Binary File (Structure : Nested List)
(xix) Write a Program in Python to create & display the contents 25
of a CSV file with student record (Roll No., Name and Total
Marks).
(xx) Write a Program in Python to search the record of students, 27
who have secured above 90% marks in the CSV file created
in last program (Program No 14).
Objective 1 :

Write a Python program to implement a stack using a list data


structure.

Program Code:

def push(a,val):
a.append(val)
def pop(a):
item=a.pop()
print("Popped Item = ",item)
def peek(a):
last=len(a)-1
print("Peek Element = ",a[last])
def display(a):
for i in range(len(a)-1,-1,-1):
print(a[i])

#__main()__
a=[]
while True:
choice=int(input("1->Push\n2->Pop\n3->Peek\n4->Display\n5-
>Exit\nEnter Your Choice : "))
if choice==1:
val=int(input("Enter Element to Push : "))
push(a,val)
print("Element Pushed Successfully...")
elif choice==2:
if len(a)==0:
print("Stack Underflow...")
else:
pop(a)
elif choice==3:
if len(a)==0:
print("Stack Underflow...")
else:
peek(a)
elif choice==4:
if len(a)==0:
print("Stack Underflow...")
else:
display(a)
else:
break

1
Output:

2
Objective 2 :
Create a student table with the student id, name, and marks as
attributes, where the student id is the primary key.

Query:
CREATE TABLE STUDENT
(STUDENTID INTEGER PRIMARY KEY,
NAME VARCHAR(30) NOT NULL,
MARKS DECIMAL(5,2));

Result:

3
Objective 3 :
Insert the details of new students in the student table.

Query:

Result:

4
Objective 4 :
Query:

Result:

5
Objective 5 :
Query:

Result:

6
Objective 6 :
Query:

Result:

7
Objective 7 :
Query:

Result:

8
Objective 8 :
Query:

Result:

9
Objective 9 :
Query:

Result:

10
Objective 10 :
Query:

Result:

11
Objective 11 :
Program Code:
Import mysql.connectors

Output:

12
Objective 12 :
Program Code:

Input:

Output:

13
Objective 13 :

Input:

Output:

14
Objective 14 :
Program Code:

Input:

Output:

15
INPUT TEXT FILE FOR PROGRAM NO. 15 & 16

16
PROGRAM - 15

Objective:
Program Code:

Output:

17
PROGRAM - 16

Objective:
Program Code:

Output:

18
PROGRAM - 17

Objective:
Program Code:

Output:

19
PROGRAM - 18

Objective:
Program Code:

Output:

20
PROGRAM - 19

Objective:
Program Code:

Output:

21
PROGRAM - 20

Objective:
Program Code:

Output:

22

You might also like