English

Computer Science (Python) Sample 2022-2023 Commerce (English Medium) Class 12 Question Paper Solution

Advertisements
Computer Science (Python) [Sample]
Marks: 70 CBSE
Commerce (English Medium)
Science (English Medium)
Arts (English Medium)

Academic Year: 2022-2023
Date: March 2023
Duration: 3h
Advertisements

General Instructions :

  1. This question paper contains five sections, Sections A to E.
  2. All questions are compulsory.
  3. Section A has 18 questions carrying 01 mark each.
  4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
  5. Section C has 05 Short Answer type questions carrying 03 marks each.
  6. Section D has 03 Long Answer type questions carrying 05 marks each.
  7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q 35 against part C only.
  8. All programming questions are to be answered using Python Language only.

SECTION - A
[1]1 | State True or False

State True or False.

“Variable declaration is implicit in Python.”

True

False

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]2

Which of the following is an invalid datatype in Python?

Set

None

Integer

Real

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]3

Given the following dictionaries.

dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}

Which statement will merge the contents of both dictionaries?

dict_exam.update(dict_result)
dict_exam + dict_result
dict_exam.add(dict_result)
dict_exam.merge(dict_result)
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
[1]4

Consider the given expression:

not True and False or True

Which of the following will be the correct output if the given expression is evaluated?

True

False

NONE

NULL

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]5

Select the correct output of the code:

a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)

Year . 0. at All the best

Year 0. at All the best

Year . 022. at All the best

Year . 0. at all the best

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]6

Which of the following mode in the file opening statement results or generates an error if the file does not exist?

a+

r+

w+

None of the above

Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
[1]7

______ command is used to remove the primary key from a table in SQL.

update

remove

alter

drop

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[1]8

Which of the following commands will delete the table from the MYSQL database?

DELETE TABLE

DROP TABLE

REMOVE TABLE

ALTER TABLE

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[1]9

Which of the following statement(s) would give an error after executing the following code?

S="Welcome to class XII" # Statement 1
print(S)       #Statement 2
S="Thank you"    # Statement 3
S[0]= '@'      # Statement 4
S=S+"Thank you"   # Statement 5

Statement 3

Statement 4

Statement 5

Statements 4 and 5

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]10

______ is a non-key attribute, whose values are derived from the primary key of some other table.

Primary Key

Foreign Key

Candidate Key

Alternate Key

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[1]11

The correct syntax of seek() is ______

file_object.seek(offset [, reference_point])
seek(offset [, reference_point])
seek(offset, file_object)
seek.file_object(offset)
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
[1]12

The SELECT statement when combined with the ______ clause returns records without repetition.

DESCRIBE

UNIQUE

DISTINCT

NULL

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[1]13

______ is a communication methodology designed to deliver both voice and multimedia communications over Internet protocol.

VoIP

SMTP

PPP

HTTP

Concept: undefined - undefined
Chapter: [0.11] Data Communication
[1]14

What will the following expression be evaluated for in Python?

print(15.0 / 4 + (8 + 3.0))

14.75

14.0

15

15.5

Concept: undefined - undefined
Chapter: [0.03] Stack
[1]15

Which function is used to display the total number of records from a table in a database?

sum(*)

total(*)

count(*)

return(*)

Concept: undefined - undefined
Chapter: [0.03] Python - Databases and SQL [0.09] Structured Query language (SQL)
[1]16

To establish a connection between Python and SQL databases, connect() is used. Which of the following arguments may not necessarily be given while calling connect()?

host

database

user

password

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[1]17 | Q17 and 18 are ASSERTION AND REASONING-based questions.

Assertion (A): If the arguments in function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.

Reasoning (R): During a function call, the argument list first contains default argument(s) followed by the positional argument(s).

Both A and R are true and R is the correct explanation for A.

Both A and R are true and R is not the correct explanation for A.

A is True but R is False.

A is false but R is True.

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[1]18

Assertion (A): CSV (Comma Separated Values) is a file format for data storage that looks like a text file.

Reason (R): The information is organized with one record on each line and each field is separated by a comma.

Both A and R are true and R is the correct explanation for A.

Both A and R are true and R is not the correct explanation for A.

A is True but R is False.

A is false but R is True.

Concept: undefined - undefined
Chapter: [0.02] Advance Programming with Python [0.02] File Handling in Python
SECTION - B
[2]19

Rao has written a code to input a number and check whether it is prime or not. His code is having errors. Rewrite the correct code and underline the corrections made.

def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[2]20
[2]20.a

Write two points of difference between Circuit Switching and Packet Switching.

Concept: undefined - undefined
Chapter: [0.11] Data Communication
Advertisements
OR
[2]20.b

Write two points of difference between XML and HTML.

Concept: undefined - undefined
Chapter: [0.05] Python - Communication Technologies [0.1] Computer Networks
[2]21
[1]21.a

Given is a Python string declaration:

myexam="@@CBSE Examination 2022@@"

Write the output of: 

print(myexam[::-2])
Concept: undefined - undefined
Chapter:
[1]21.b

Write the output of the code given below:

my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())
Concept: undefined - undefined
Chapter: [0.08] Database Concepts
[2]22

Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.

Concept: undefined - undefined
Chapter: [0.08] Database Concepts
[2]23
[1]23.a
[0.5]23.a.i

Write the full form of the following:

SMTP

Concept: undefined - undefined
Chapter: [0.11] Data Communication
[0.5]23.a.ii

Write the full form of the following:

PPP

Concept: undefined - undefined
Chapter: [0.11] Data Communication
[1]23.b

What is the use of TELNET?

Concept: undefined - undefined
Chapter: [0.11] Data Communication
[2]24
[2]24.a

Predict the output of the Python code given below:

def Diff(N1,N2):
 if N1>N2:
 return N1-N2
 else:
 return N2-N1

NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
 A=NUM[CNT]
 B=NUM[CNT-1]
 print(Diff(A,B),'#', end=' ')
Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
OR
[2]24.b

Predict the output of the Python code given below:

tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
 if i%2==0:
 new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
[2]25
[2]25.a

Differentiate between count() and count(*) functions in SQL with appropriate examples.

Concept: undefined - undefined
Chapter: [0.03] Python - Databases and SQL [0.09] Structured Query language (SQL)
OR
[2]25.b

Categorize the following commands as DDL or DML:

INSERT, UPDATE, ALTER, DROP

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
SECTION - C
[3]26
[1]26.a

Consider the following tables – Bank_Account and Branch:

Table: Bank_Account

ACode Name Type
A01 Amrita Savings
A02 Parthodas Current
A03 Miraben Current

Table: Branch

ACode City
A01 Delhi
A02 Mumbai
A01 Nagpur

What will be the output of the following statement?

SELECT * FROM Bank_Account NATURAL JOIN Branch;

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[2]26.b

Write the output of the queries based on the table, TECH_COURSE given below:

Table: TECH_COURSE
CID CNAME FEES STARTDATE TID
C201 Animation and VFX 12000 2022-07-02 101
C202 CADD 15000 2021-11-15 NULL
C203 DCA 10000 2020-10-01 102
C204 DDTP 9000 2021-09-15 104
C205 Mobile Application
Development
18000 2022-11-01 101
C206 Digital Marketing 16000 2022-07-25 103
  1. SELECT DISTINCT TID FROM TECH_COURSE;
  2. SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID HAVING COUNT(TID)>1;
  3. SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY CNAME;
  4. SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000 AND 17000;
Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[3]27
[3]27.a

Write a method COUNTLINES() in Python to read lines from the text file ‘TESTFILE.TXT’ and display the lines which do not start with any vowel.

Example:

If the file content is as follows:

An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.

The COUNTLINES() function should display the output as:

The number of lines not starting with any vowel - 1

Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
Advertisements
OR
[3]27.b

Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and T individually (including small cases e and t too).

Example:

If the file content is as follows:

Today is a pleasant day.
It might rain today.
It is mentioned on weather sites

The ETCount() function should display the output as:
E or e : 6
T or t : 9

Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
[3]28
[2]28.a

Write the outputs of the SQL queries based on the relations Teacher and Placement given below:

Table: Teacher

T_ID Name Age Department Date_of_join Salary Gender
1 Arunan 34 Computer Sc 2019-01-10 12000 M
2 Saman 31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4 Samira 35 History 2018-07-01 40000 F
5 Raman 42 Mathematics 2021-09-05 25000 M
6 Shyam 50 History 2019-06-27 30000 M
7 Shiv 44 Computer Sc 2019-02-25 21000 M
8 Shalakha 33 Mathematics 2018-07-31 20000 F

Table: Placement

P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur
  1. SELECT Department, avg(salary) FROM Teacher GROUP BY Department;
  2. SELECT MAX(Date_of_Join), MIN(Date_of_Join) FROM Teacher;
  3. SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE T.Department = P.Department AND Salary>20000;
  4. SELECT Name, Place FROM Teacher T, Placement P WHERE Gender = ’F’ AND T.Department = P.Department;
Concept: undefined - undefined
Chapter: [0.03] Python - Databases and SQL [0.09] Structured Query language (SQL)
[1]28.b

Write the command to view all tables in a database.

Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[3]29

Write a function INDEX_LIST(L), where L is the list of elements passed as arguments to the function. The function returns another list named ‘indexList’ that stores the indices of all Non-Zero Elements of L.

For example:

If L contains [12, 4, 0, 11, 0, 56]

The indexList will have - [0, 1, 3, 5].

Concept: undefined - undefined
Chapter: [0.01] Exceptional Handling in Python
[3]30
[3]30.a

A list contains the following record of a customer: [Customer_name, Phone_number, City]

Write the following user-defined functions to perform given operations on the stack named ‘status’:

  1. Push_element() - Push an object containing the name and Phone number of customers who live in Goa to the stack.
  2. Pop_element() - Pop the objects from the stack and display them. Also, display “Stack Empty” when there are no elements in the stack.

For example:

If the lists of customer details are:

[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”] [“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]

The stack should contain

[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:

[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty

Concept: undefined - undefined
Chapter:
OR
[3]30.b

Write a function in Python, Push(SItem) where SItem is a dictionary containing the details of stationery items - {Sname:price}. The function should push the names of those items in the stack that have a price greater than 75. Also, display the count of elements pushed into the stack.

For example:

If the dictionary contains the following data:

Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

The stack should contain
Notebook
Pen

The output should be:
The count of elements in the stack is 2

Concept: undefined - undefined
Chapter:
SECTION - D
[5]31

MakeInIndia Corporation, a Uttarakhand-based IT training company, is planning to set up training centres in various cities in the next 2 years. Their first campus is coming up in the Kashipur district. At the Kashipur campus, they are planning to have 3 different blocks for App development, Web designing, and Movie editing. Each block has a number of computers, which are required to be connected to a network for communication, data, and resource sharing. As a network consultant of this company, you have to suggest the best network-related solutions for the issues/problems raised in questions keeping in mind the distances between various blocks/locations and other given parameters.

Distance between various blocks/locations:

Block Distance
App development to Web Designing 28 m
App development to Movie Editing 55 m
Web designing to Movie Editing 32 m
Kashipur Campus to Mussoorie Campus 232 km

Number of computers

Block Number of Computers
App development 75
Web Designing 50
Movie editing 80
  1. Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out of the 3 blocks) to get the best and most effective connectivity. Justify your answer.
  2. Suggest a device/software be installed in the Kashipur Campus to take care of data security.
  3. Suggest the best-wired medium and draw the cable layout (Block to Block) to economically connect various blocks within the Kashipur Campus.
  4. Suggest the placement of the following devices with appropriate reasons:
    a. Switch/Hub
    b. Repeater
  5. Suggest a protocol that shall be needed to provide a Video Conferencing solution between Kashipur Campus and Mussoorie Campus.
Concept: undefined - undefined
Chapter: [0.05] Python - Communication Technologies [0.12] Security Aspects
[5]32
[5]32.a
[2]32.a.i

Write the output of the code given below:

p=5
def sum(q,r=2):
      global p
      p=r+q**2
      print(p, end= '#')

a=10
b=5
sum(a,b)
sum(r=5,q=1)
Concept: undefined - undefined
Chapter: [0.03] Stack
[3]32.a.ii

The code given below inserts the following record in the table Student:

RollNo - integer
Name - string
Clas - integer
Marks - integer

Note the following to establish connectivity between Python and MYSQL:

  • Username is root
  • Password is tiger
  • The table exists in an MYSQL database named school.
  • The details (RollNo, Name, Clas and Marks) are to be accepted by the user.

Write the following missing statements to complete the code:

Statement 1 - to form the cursor object.

Statement 2 - to execute the command that inserts the record in the table Student.

Statement 3 - to add the record permanently to the database.

import mysql.connector as mysql
def sql_data():
        con1=mysql.connect(host="localhost",user="root",password="tiger", database="school")
 mycursor=_________________ #Statement 1 
 rno=int(input("Enter Roll Number :: "))
 name=input("Enter name :: ")
 clas=int(input("Enter class :: "))
 marks=int(input("Enter Marks :: "))
 querry="insert into student 
values({},'{}',{},{})".format(rno,name,clas,marks)
--------------------#Statement 2
--------------------# Statement 3
 print("Data Added successfully")
Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
OR
[5]32.b
[2]32.b.i

Predict the output of the code given below:

s="welcome2cs" 

n = len(s)
m=""
for i in range(0, n):
       if (s[i] >= 'a' and s[i] <= 'm'):
            m = m +s[i].upper()
 elif (s[i] >= 'n' and s[i] <= 'z'):
          m = m +s[i-1]
 elif (s[i].isupper()):
     m = m + s[i].lower()
 else:
     m = m +'&'
print(m)
Concept: undefined - undefined
Chapter: [0.03] Python - Databases and SQL [0.09] Structured Query language (SQL)
[3]32.b.ii

The code given below reads the following record from the table named student and displays only those records that have marks greater than 75:

  • RollNo - integer
  • Name - string
  • Clas - integer
  • Marks - integer

Note the following to establish connectivity between Python and MYSQL:

  • Username is root.
  • The password is the tiger.
  • The table exists in an MYSQL database named school.

Write the following missing statements to complete the code:

Statement 1 - to form the cursor object
Statement 2 - to execute the query that extracts records of those students whose marks are greater than 75.
Statement 3 - to read the complete result of the query (records whose marks are greater than 75) into the object named data, from the table student in the database.

import mysql.connector as mysql
def sql_data():
       con1=mysql.connect(host="localhost",user="root",password="tiger", database="school")
       mycursor=_______________ #Statement 1
       print("Students with marks greater than 75 are :")
                  _________________________ #Statement 2
                 data=__________________ #Statement 3
                for i in data:
                   print(i)
                print()
Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[5]33
[5]33.a

What is the advantage of using a CSV file for permanent storage? Write a Program in Python that defines and calls the following user-defined functions:

  1. ADD() - To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a list with field elements such as empid, name, and mobile to store an employee id, employee name, and employee salary respectively.
  2. COUNTR() - To count the number of records present in the CSV file named ‘record.csv’.
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
OR
[5]33.b

Give any one point of difference between a binary file and a CSV file. Write a Program in Python that defines and calls the following user-defined functions:

  1. add() - To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists of a list with field elements such as fid, fname, and fprice to store furniture id, furniture name, and furniture price respectively.
  2. search() - To display the records of the furniture whose price is more than 10000.
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python
SECTION - E
[4]34

Navdeep creates a table RESULT with a set of records to maintain the marks secured by students in Sem1, Sem2, Sem3, and their divisions. After the creation of the table, he entered data of 7 students in the table.

ROLL_NO SNAME SEM1 SEM2 SEM3 DIVISION
101 KARAN 366 410 402 I
102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II
107 NEELAM 470 450 471 I

Based on the data given above answer the following questions:

  1. Identify the most appropriate column, which can be considered as the Primary key.
  2. If two columns are added and 2 rows are deleted from the table result, what will be the new degree and cardinality of the above table?
  3. Write the statements to:
    a. Insert the following record into the table
    Roll No - 108, Name - Aadit, Sem1- 470, Sem2 - 444, Sem3 - 475, Div - I.
    b. Increase the SEM2 marks of the students 3% whose name begins with ‘N’.
    OR
    Write the statements to:
    a. Delete the record of students securing IV division.
    b. Add a column REMARKS in the table with datatype as varchar with 50 characters.
Concept: undefined - undefined
Chapter: [0.09] Structured Query language (SQL)
[4]35

Aman is a Python programmer. He has written a code and created a binary file record.dat with employeeid, ename, and salary. The file contains 10 records.

He now has to update a record based on the employee id entered by the user and update the salary. The updated record is then to be written in the file temp.dat. The records which are not to be updated also have to be written to the file temp.dat. If the employee id is not found, an appropriate message should be displayed.

As a Python expert, help him to complete the following code based on the requirement given above:

import _______ #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb") 
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
 found=True 
   rec["Salary"]=int(input("Enter new salary :: "))
   pickle.____________ #Statement 4
else:
   pickle.dump(rec,fout)
except:
  break
if found==True:
print("The salary of employee id ",eid," has
been updated.")
else:
print("No employee with such id is not found")
 fin.close()
fout.close()
  1. Which module should be imported into the program? (Statement 1)
  2. Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
  3. Which statement should Aman fill in Statement 3 to read the data from the binary file, record.dat, and in Statement 4 to write the updated data in the file, temp.dat?
Concept: undefined - undefined
Chapter: [0.02] File Handling in Python

Other Solutions



































Submit Question Paper

Help us maintain new question papers on Shaalaa.com, so we can continue to help students




only jpg, png and pdf files

CBSE previous year question papers Class 12 Computer Science (Python) with solutions 2022 - 2023

     CBSE Class 12 Computer Science (Python) question paper solution is key to score more marks in final exams. Students who have used our past year paper solution have significantly improved in speed and boosted their confidence to solve any question in the examination. Our CBSE Class 12 Computer Science (Python) question paper 2023 serve as a catalyst to prepare for your Computer Science (Python) board examination.
     Previous year Question paper for CBSE Class 12 Computer Science (Python)-2023 is solved by experts. Solved question papers gives you the chance to check yourself after your mock test.
     By referring the question paper Solutions for Computer Science (Python), you can scale your preparation level and work on your weak areas. It will also help the candidates in developing the time-management skills. Practice makes perfect, and there is no better way to practice than to attempt previous year question paper solutions of CBSE Class 12.

How CBSE Class 12 Question Paper solutions Help Students ?
• Question paper solutions for Computer Science (Python) will helps students to prepare for exam.
• Question paper with answer will boost students confidence in exam time and also give you an idea About the important questions and topics to be prepared for the board exam.
• For finding solution of question papers no need to refer so multiple sources like textbook or guides.
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×