12th Computer Science Annual Exam Question Paper1
12th Computer Science Annual Exam Question Paper1
com
Section A:
Python – 12 Marks
DBMS – 6 Marks
Networking – 3 Marks
17. Networking –
18. Networking –
19. Networking – One Liner
20. Assertion & Reasoning – Python
21. Assertion & Reasoning – DBMS
Section B:
Python – 10 Marks
DBMS – 2 Marks
Networking – 2 Marks
Section C:
Python – 9 Marks
DBMS – 0 Marks
Networking – 0 Marks
Section D:
Python – 4 Marks
DBMS – 12 Marks
Networking – 0 Marks
32. MySQL
A Single table given and write the SQL query for 4 statements
OR – Internal Choice
Four SQL query givens on same table and write the output of those query
33. CSV File Program – Python
34. MySQL
Two tables given followed by 4 statements to write the SQL query of those statements, in 4th
statement there is an internal choice.
Section E:
Python – 5 Marks
DBMS – 0 Marks
Networking – 5 Marks
Unit – 1
Chapter: 1- Function:
1. Types of Functions:
Types of Functions
Built - in/Pre-defined
Functions in Modules User Defined Functions
Functions
2. Types of Arguments:
Types of
Arguments
4. Scope of variable:
a. local variable
b. nonlocal variable
c. global variable
1. try
2. except
3. else
4. finally
5. raise
6. assert
Exception Handling is a process to handle exception of a program by which program can run in
normal flow.
Common Exceptions:
ValueError: a function is called on a value of the correct type, but with an inappropriate value.
Text File:
A text file consists of human readable characters, which can be opened by any text editor.
Files with extensions like .txt, .py, .csv, etc. are some examples of text files.
Each line of a text file is terminated by a special character, called the End of Line (EOL). For
example, the default EOL character in Python is the newline (\n).
Text file data can be represented in ASCII or UNICODE.
Binary File:
Binary files are stored in a computer in a sequence of bytes.
Binary files are stored in terms of bytes (0s and 1s)
Data (bytes) of binary file do not represent the ASCII OR UNICODE values of characters.
Binary files are used to store content such as image, audio, video, compressed versions of other
files, executable files, etc.
Relative and Absolute paths:
A path is a string that specifies the location of a file or folder in a file system . There are two
types of paths: relative and absolute.
Relative path
A relative path is a path that is relative to the current working directory of the program or the
user. It describes the location of a file or folder without starting from the root of the file system.
For example, if the current working directory is “D:\python programs”, then the relative path of
“abc.txt” in the same folder is just “abc.txt”. Similarly, the relative path of “spsc.txt” in a
subfolder named “SPSC” is “SPSC\spsc.txt”.
Absolute path
An absolute path is a path that starts from the root of the file system. It describes the location of
a file or folder regardless of the current working directory of the program or the user.
f=open("d:\\abc.txt","r")
data=f.read() # Read all characters of the file from the file pointer
print(data)
writelines(): writelines() function is used for writing the list of the string in the file at once. It can also
accept the tuple of strings, the set of strings, any iterable object etc.
f=open("d:\\abc.txt","w")
data=f.write("Hello From Python") #Write the string into text file, older content if any removed
Pickling: It is the process of converting python object into byte stream. Pickling is done at the time of
writing into a binary file.
Unpickling: It is the process of converting a byte stream into python object. Unpickling is done at the
time reading from a binary file.
load() method of pickle module is used to read data from binary file and dump() method of pickle
module is used to write data into binary file.
dump():
Syntax: identifier = pickle.dump(data , file_pointer)
data= “Hello from SPSC”
pickle.dump(data,f) #here ‘data’ contains data and ‘f’ is a file pointer.
load( ):
Syntax: identifier = pickle.load(file_pointer)
Example: data = pickle.load(f) #Here ‘data’ is an identifier and ‘f’ is a file pointer
import pickle
f=open("d:\\abc.dat","wb")
pickle.dump(data,f)
f.close()
f=open("d:\\abc.dat","rb")
d=pickle.load(f)
print(d)
f.close()
import csv
f=open("student.csv","w",newline='')
cw=csv.writer(f)
cw.writerow(['Rollno','Name','Marks'])
for i in range(5):
print("Student Record of ",(i+1))
rollno=int(input("Enter Roll No. : "))
name=input("Enter Name: ")
marks=float(input("Enter Marks: "))
sr=[rollno,name,marks]
cw.writerow(sr)
f.close()
print("File Created Successfully")
Chapter: 4- Stack:
Stack – follow the approach of LIFO – Last In First Out
Stack=[]
L=[['Amit','Delhi',75000],['Rohit','Shimla',95000],['Ajay','Srinagar',97000]]
def Push_emp(Stack,L1):
for i in L1:
if i[1].startswith('S') and i[2]>90000:
Stack.append(i)
print(Stack)
def Pop_emp(Stack):
while Stack!=[]:
print(Stack.pop())
else:
print("Stack Empty")
Push_emp(Stack,L)
Pop_emp(Stack)
DBMS - MySQL
SQL (Structured Query Language)
Types of SQL Query:
1: Sum()
2: Max()
3: Min()
4: Avg()
5: Count()
Python-MySQL connectivity:
import mysql.connector
con=mysql.connector.connect(host="localhost",username="root",passwd="root")
mycursor=con.cursor()
mycursor.execute("create database if not exists spsharmag")
mycursor.execute("use spsharmag")
mycursor.execute("create table if not exists Employee (eid int primary key, ename
varchar(20), salary float(8,2))")
c="y"
while(c=="y" or c=="Y"):
print("1. Press 1 for add new Employee: ")
print("2. Press 2 for Show the details of Employees: ")
print("3. Press 3 for Update Employee Details: ")
print("4. Press 4 for Delete Employee Details: ")
print("5. Press 5 for Exit: ")
choice=int(input("Enter Your Choice 1 or 2 or 3 or 4 or 5: "))
if(choice==1):
Networking:
1. Server placed in that block in which maximum computer available
2. Star topology is best for creating layout – connect server block to all other block to create
the layout
3. Switch or hub placed in each and every block
4. Repeater placed between the block which distance is 100 mtr or more.
5. VoIP protocol for video conference