0% found this document useful (0 votes)
32 views14 pages

12th Computer Science Annual Exam Question Paper1

The document outlines the structure and content of a 12th-grade Computer Science annual exam, detailing various units such as Computational Thinking, Computer Networks, and Database Management, along with specific question formats and marks distribution. It includes revision tips on Python programming, exception handling, file handling, and SQL queries, providing examples and explanations for each topic. Additionally, it covers practical applications like stack operations and MySQL connectivity in Python.

Uploaded by

jsmriti67
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)
32 views14 pages

12th Computer Science Annual Exam Question Paper1

The document outlines the structure and content of a 12th-grade Computer Science annual exam, detailing various units such as Computational Thinking, Computer Networks, and Database Management, along with specific question formats and marks distribution. It includes revision tips on Python programming, exception handling, file handling, and SQL queries, providing examples and explanations for each topic. Additionally, it covers practical applications like stack operations and MySQL connectivity in Python.

Uploaded by

jsmriti67
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/ 14

S P SHARMA SIR 7048972696 support@spsharmag.

com

12th Computer Science Annual Exam


Question Papers
Unit 1: Computational Thinking and Programming – 2 (Python) – 40 Marks

Unit 2: Computer Networks – 10 Marks

Unit 3: Database Management – 20 Marks

Section A: 21 Qus * 1 = 21 Marks

Section B: 7 Qus * 2 = 14 Marks

Section C: 3 Qus * 3 = 09 Marks

Section D: 4 Qus * 4 = 16 Marks

Section E: 2 Qus * 5 = 10 Marks

Section A:
Python – 12 Marks

DBMS – 6 Marks

Networking – 3 Marks

1. True/ False – Python


2. String Output – Python
3. Operator – Python
4. String Output – Python
5. Slicing Output – Python
6. Tuple Output – Python
7. Dictionary Output – Python
8. List – Python
9. DBMS –
10. File Handling – Python
11. True/False – Python
12. Function Output – Python
13. DBMS – One Liner
14. DBMS –
15. DBMS –
16. DBMS –

1 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

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

22. Python Correct Code


23. Python Operator
24. Python Sequence Functions – Internal Choice
25. Python random module MCQ / Value Output
26. Python Function Code Output
27. DBMS – Internal Choice
28. Networking – Internal Choice

Section C:
Python – 9 Marks

DBMS – 0 Marks

Networking – 0 Marks

29. Text File Program – Python – Internal Choice


30. Stack Program – Python – Internal Choice
31. Python Looping Output Program – Python – Internal Choice

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.

2 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

35. Python – MySQL connectivity Program - DBMS

Section E:
Python – 5 Marks

DBMS – 0 Marks

Networking – 5 Marks

36. Binary File Program – Python


37. Networking Case Study – 5 Statements based questions

Unit – 1
Chapter: 1- Function:
1. Types of Functions:

Types of Functions

Built - in/Pre-defined
Functions in Modules User Defined Functions
Functions

print(), input(), int(), def show():


float(), eval(), len(), sum(), math module random module statistics module print("Hello")
type() etc. show()

sin(), cos(), tan(), floor(), random(), randint(),


mean(), mode(), median()
ceil(), sqrt() etc. randrange()

3 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

2. Types of Arguments:

Types of
Arguments

Positional Keyword/Named Default Variable Length


Arguments Arguments Arguments Arguments

3. Function return statement:


a. Function return ‘None’
b. Function return a single value
c. Function return multiple values
d. Early exit from function
e. Unreachable code

4 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

5 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

4. Scope of variable:
a. local variable
b. nonlocal variable
c. global variable

6 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

Chapter: 2- Exception Handling:


Keywords of Exception Handling:

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:

ImportError: an import fails;

IndexError: It is raised when index of a sequence is out of the range

NameError: an unknown variable is used;

SyntaxError: the code can't be parsed properly;

TypeError: a function is called on a value of an inappropriate type;

ValueError: a function is called on a value of the correct type, but with an inappropriate value.

7 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

Chapter: 3- File Handling:


Types of File:
There are mainly two types of data files —
 Text file
 .txt files
 .csv file (Comma Separated Values)
 Binary file

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.

8 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

 For example, the absolute path of “abc.txt” in “D:\python programs” is “D:\python


programs\abc.txt”. Similarly, the absolute path of “spsc.txt” in a subfolder named “SPSC” is
“D:\python programs\SPSC\spsc.txt”.
File opening mode/Access Specifiers in Files:

Mode Text/CSV File Binary File


Read Mode r rb
Write Mode w wb
Append Mode a ab
Read and Write Mode r+ rb+
Write and Read Mode w+ wb+

Read data from a text file:


Following methods are used to read the content of a text file:
(a) read() : Read the entire content of the file character by character from the file pointer
(b) read(n) : Read maximum ‘n’ characters of the file character by character from the file pointer. If
n is negative read entire file
(c) readline() : Read the content of the file till EOL(End of Line) character (\n) from the file pointer
(d) readline(n) : Read maximum ‘n’ character from the file pointer to End of line character. If n is
negative read entire line.
(e) readlines() : Read all the lines of the file from the file pointer and store each line as an element
of list with ‘\n’ and return the list of lines/string.
(f) readlines(n) : Read the complete line till ‘n’ number of characters from the file pointer. Return
complete line in which file pointer. If n is negative read all lines and return list of all lines.

f=open("d:\\abc.txt","r")
data=f.read() # Read all characters of the file from the file pointer
print(data)

Write data into Text File:


write(): write() function is used for writing the string in the text file.

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

9 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

f.close() #file must be closed if opened in write and append mode


print("File Created")

seek( ) & tell( ):


seek( ):
seek() function is used to change the position of the File Handler to a given specific position. File
handler is like a cursor, which defines from where the data has to be read or written in the file.
Syntax:
<file_object>.seek(<offset>,<from_where>)
Reference Point:
0: sets the reference point at the beginning of the file. (Default)
1: sets the reference point at the current file position.
2: sets the reference point at the end of the file
Note: In the case of a text file we can use only ‘0’ as a reference point.
tell( ):
tell() function returns the current position of the file object/handler. It does not take any arguments
and returns an integer value.
Syntax: <file_object>.tell( )

Working in Binary files:

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.

10 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

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")

data="Hello from SPSC"

pickle.dump(data,f)

f.close()

f=open("d:\\abc.dat","rb")

d=pickle.load(f)

print(d)

f.close()

Working in CSV files:

 CSV stands for Comma Separated Values.


 CSV file is a plain text file which stores data in a tabular format, where each row represents
 a record and each column represents a field and fields are separated by comma.
 csv module is used for working with csv files
 File extension for csv file will be .csv
 CSV module provides two main classes for working with csv files are:
 reader
 writer
 CSV reader object can be used to iterate/read the rows of the CSV file.
 For reading data from csv file we require csv.reader( ) function.
 CSV writer object that can be used to write row(s) to the CSV file
 writerow(): This method is used to write a single row to the CSV file.
 writerows(): This method is used to write multiple rows to the CSV file.

11 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

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

Operations on Stack: PUSH and POP

Add/Insert an element into stack – PUSH using append() method

Delete/Remove and element from stack – POP using pop() method

Underflow: Try to remove an element from empty stack

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)

12 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

DBMS - MySQL
SQL (Structured Query Language)
Types of SQL Query:

1. DDL – Data Definition Language - Alter, Truncate, Create, Drop


2. DML – Data Manipulation Language – Delete, Insert, Update
3. DQL – Data Query Language - Select
4. DCL – Data Control Language – grant, revoke
5. TCL – Transaction Control Language – commit, rollback

Types of Aggregate functions:

1: Sum()
2: Max()
3: Min()
4: Avg()
5: Count()

Some Important Questions:


 Difference between char and varchar
 Difference between delete, drop and truncate
 Difference between where, having and group by
 Difference between count(), count(*) and count(Column_name)
 Explain Primary, Foreign, Unique and Candidate keys
 What is Join? Explain different types of Join in SQL.
 Like operator
 Alter and group by command examples

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):

13 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com


S P SHARMA SIR 7048972696 support@spsharmag.com

eid=int(input("Enter Employee Id: "))


ename=input("Enter Employee Name: ")
salary=input("Enter Employee Salary: ")
mycursor.execute("insert into Employee values(%s,%s,%s)",(eid,ename,salary))
con.commit()
elif(choice==2):
mycursor.execute("select * from Employee")
myemp=mycursor.fetchall()
for x in myemp:
print(x)
elif(choice==3):
eid=int(input("Enter the Employee id for update: "))
ename=input("Enter Employee New Name: ")
salary=input("Enter Employee New Salary: ")
mycursor.execute("update Employee set
ename=%s,salary=%s where eid=%s",(ename,salary,eid))
con.commit()
elif(choice==4):
eid=int(input("Enter the Employee id for delete: "))
mycursor.execute("delete from Employee where
eid=%s",(eid,))
con.commit()
elif(choice==5):
break
else:
print("Wrong Choice")
c=input("Press 'y' for continue and 'n' for exit: ")

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

Some Important Questions:


 Difference between Switch, Hub, Router, Modem
 Full Form of networking Terms
 Guided and Unguided media
 Networking Protocols
 Switching Techniques
 PAN, LAN, MAN, WAN and Types of Topologies
 HTML vs XML
 add-ons and plugins, cookies

14 CLASS 12 CS LAST TIME REVISION TIPS www.spsharmaclasses.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy