In this article, we are going to Sample Paper Computer Science Class 12 Session 2023-24. CBSE released a sample paper along with the syllabus on 01.04.2023. Here I will provide you with a detailed analysis of sample papers and some more practice papers for the board exam 2024. So let us begin!

New Paper pattern for Sample Paper Computer Science Class 12 Session 2023-24

For the academic year 2023-24, CBSE has changed the paper pattern and assessment scheme via circular Acad-45/2023 dated 06.04.2023. The Board is introducing changes to Examination and Assessment practices to align assessment to Competency Focused Education, with a greater number of Competency Based Questions or questions that assess the application of concepts in real-life situations.

So let us review the previous year as well as the current year’s assessment and evaluation practices to be followed by the board.

Question Types2022-232023-24
Competency-based questions30% in the form of Multiple Choice, Case-Based Questions, Source Based Integrated Questions or any other type40% in the form of MCQs/Case Based Questions, Source-based Integrated Questions or any other type
Objective type questions20%20% – Response Type Questions (MCQ)
Short Answer/Long Answer Questions50%40% – Constructed Response Type

Highlights of Sample Paper Computer Science Class 12 Session 2023-24

Some important highlights of Sample Paper Computer Science Class 12 Session 2023-24 are as follows:

  1. Sample Paper Computer Science Class 12 Session 2023-24 contains 35 questions.
  2. Sample Paper Computer Science Class 12 Session 2023-24 divided into 5 sections – A to E.
  3. Section A – 18 Questions (1-18), Each question of 1 mark.
  4. Section B – 7 Questions (19-25), Each question of 2 marks.
  5. Section C – 5 Questions (26-30), Each question of 3 marks.
  6. Section D – 3 Questions (31-33), Each question of 5 marks.
  7. Section E – 2 Questions (34 & 35), Each question of 4 marks.
  8. All programming questions are to be answered using Python language only.

Lets us discuss the sample paper now. I have explained every question in detail. So here we go!

Sample Paper Complete Analysis Chapter wise/Question Wise

I have analyzed sample papers with each question chapter-wise. Here it is:

NoChapter & TopicMarks
Section A
1Ch:1 Python Revision Tour – I,  Loops and Jump Statements1
2Ch:13 Simple queries in SQL, Data Types1
3Ch:1 Python Revision Tour – I,  Evaluating Expressions1
4Ch:2 Python Revision Tour – II, Strings in Python1
5Ch:15 Grouping Records, Joins in SQL – Cartesian Product1
6Ch:10 Computer Networks – I, Types of networks1
7Ch:2 Python Revision Tour – II , Lists in Python1
8Ch:2 Python Revision Tour – II , Strings in Python1
9Ch:2 Python Revision Tour – II , Tuples in Python1
10Ch: 4 Using Python Libraries, Working with standard library modules1
11Ch:11 Computer Networks – II, Network Devices1
12Ch:3, Working with functions, Scope of variables1
13Exception handling newly added topic (Appendix – E) Provided Later1
14Ch:12 Relational Databases, The relational model terminology1
15Ch:10 Computer Networks – I1
16Ch:5 File handling, Working with text files1
17Ch:2 Python Revision Tour – II, Lists in Python1
18Ch: 3 Working with functions, Types of functions1
Revision Tour – I: 3
Revision Tour – II:5
Working with functions: 2
Using Python Libraries:1
File Handling:1
Computer Networks – I :2
Computer Networks – II:1
Relational Databases:1
Simple Queries in SQL:1
Grouping Records, Joins in SQL:1
 
Section B
19(i) Ch: 11 Computer Networks – II, Network Protocols and Internetworking Terms & Concepts
(ii) Ch:11 Computer Networks – II, Internetworking Terms & Concepts
1
 
1
202 Errors from Ch1: Python Revision Tour – I  (While,==)
2 Errors from Ch 3: Working with functions (define, return)
1
1
21Ch2: Python revision tour – II, Lists in Python OR
Ch:2 Python revision tour – II, Strings in python
2
22Ch2: Python revision tour – II, Strings, Lists and Dictionaries in Python2
23Ch2: Python revision tour – II, Strings and Lists in Python2
24Ch14: Table creation and Data Manipulation Commands, DDL and DML command2
25Ch3: Working with functions, Passing Parameters2
Revision Tour – I: 1 (Err)
Revision Tour – II:3+1 (1 OR )
Working with Functions:1 (Err)+1
Computer Networks – II:1
Table Creation & DDL and DML commands:1
 
Section C
26Ch2: Python Revision Tour – II, Strings in Python3
27Ch13: Simple queries in SQL, Simple Queries and Aggregate Functions3
28Ch5: File Handling, Working with Text Files : 2 with OR3
29Ch13: Simple Queries in SQL (1M)
Ch14: Data Manipulation Commands (2M)
3
30Ch9: Data Structure – II Stack3
Python Revision Tour – II:1
File Handling: 1+1(OR)
Simple Queries: 1, 1(1M)
SQL Commands – 1(2M)
Data Structure -1
 
Section D
31Ch:10 Computer Networks – I , 3 Media and topologies
Ch:11 Computer Networks – II, 2 Network Devices, Security
5
32Ch5: File handling, i) Working with text files (2M)                                  
ii) Working with Binary Files (Including OR) (3M)
5
33Ch12: Relational Databases, i) Relational Model Terminologies(1M)
Ch16: ii) Interface Python with MySQL (4M)
5
File handling:1+1 (Inc OR)
Computer Networks:1
Relational Databases:1
Python Connectivity – 1 (4M)
 
Section E
34DBMS4
35File Handling –CSV File4
File Handling,CSV:1DBMS:1 

No.Chapter1M2M3M4M5MTotalMarks
1 & 2Revision Tour I & II8+14*114*20-2=18
3Working with Functions2+1145
4Using Python Libraries111
5File Handling12*12*6*13
9Stack113
10 & 11Computer Networks311510
12 to 15DBMS3121715
16Python Connectivity115
Total questions including OR187*+16*24*38*70
Extra (OR)1113 
Questions to be Attempted18752335 
Section wise Marks18141581570 

Watch this video for blueprint understanding:

Section A Sample Paper Computer Science Class 12 Session 2023-24

  1. State True or False: “In a Python program, if a break statement is given in a nested loop, it terminates the execution of all loops in one go.”
    • Ans. – False: In a nested loop, the inner loop will be terminated and the outer loop executes the number of times.
  2. In a table in MYSQL database, an attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of datatype char(20) has value “Meenakshi”. How many characters are occupied by attribute A and attribute B?
    • a. 20,6
    • b. 6,20
    • c. 9,6
    • d. 6,9
    • Ans.: b. 6,20 – Varchar is a variable length data type hence, the value “Keshav” has 6 letters and the char data type is a fixed length data type, hence it occupies 20 characters.
  3. What will be the output of the following statement: print(3-2**2**3+99/11)
    • a. 244
    • b. 244.0
    • c. -244.0
    • d. Error
    • Ans.: c. -2444.0, As per the operator precedence 2**3 evaluate first. So the expression will be 3-2**8+99/11, then 2**8 will be evaluated i.e. 256. After this, 99/11 will be evaluated to 9.0. Hence the expression becomes 3-256+9.0, then -256+12.0 and finally, it returns -244.0
  4. Select the correct output of the code:
    • s=”Python is fun”
    • l=s.split()
    • s_new=”-“.join([l[0].upper()],l[1],l[2].capitalize()])
    • print(s_new)
      • a. PYTHON-IS-Fun
      • b. PYTHON-is-Fun
      • c. Python-is-fun
      • d. PYTHON-Is -Fun
      • Ans.: b. PYTHON-is-Fun, The list object l contains [‘Python’,’is”,’fun’], it will join each word with -. l[0] refers to Python which is converted into upper case, Hence its evaluates to PYTHON then l[1] i.e. ‘is’ and fun converted into capitalize so becomes “Fun”.
  5. In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has degree 3 and cardinality 5, what will be the degree and cardinality of the Cartesian product of Alpha and Beta?
    • a. 5,3
    • b. 8,15
    • c. 3,5
    • d. 15,8
    • Ans.: b. 8,15, In the Cartesian product the number of columns will be added and rows will be multiplied. So degree refers to no. of columns and cardinality refers to no. of rows. So here degree 5+3 = 8, cardinality 3*5=15.
  6. Riya wants to transfer pictures from her mobile phone to her laptop. She uses Bluetooth Technology to connect two devices. Which type of network will be formed in this case?
    • a. PAN
    • b. LAN
    • c. MAN
    • d. WAN
    • Ans.: a. PAN, When individuals share files using Bluetooth or wifi is considered as PAN network.
  7. Which of the following will delete key-value pair for key = “Red” from a dictionary D1?
    • a. delete D1(“Red”)
    • b. del D1[“Red”]
    • c. del.D1[“Red”]
    • d. D1.del[“Red”]
    • Ans.: b. del D1[“Red”], The del keyword requires a value from dictionary and the syntax for del is del <element>. Option b is correct.
  8. Consider the statements given below and then choose the correct output from the given options:
    • pride=”#G20 Presidency”
    • print(pride[-2:2:-2])
      • a. ndsr
      • b. ceieP0
      • c. ceieP
      • d. yndsr
    • Ans.: b. ceieP0, The slicing starts from the -2 index which is c, the step value is -2 and the stop value is 2. The slicing will get every alternate character by skipping 1 value up to 2.
  9. Which of the following statement(s) would give an error during execution of the following code?
    • tup = (20,30,40,50,80,79)
    • print(tup) #Statement 1
    • print(tup[3]+50) #Statement 2
    • print(max(tup)) #Statement 3
    • tup[4]=80 #Statement 4
      • a. Statement 1
      • b. Statement 2
      • c. Statement 3
      • d. Statement 4
      • Ans.: d. tup[4]=80, Tuple immutable hence tuple value cannot be changed.
  10. What possible outputs(s) will be obtained when the following code is executed?
    • import random
    • myNumber=random.randint(0,3)
    • COLOR=[“YELLOW”,”WHITE”,”BLACK”,”RED”]
    • for I in COLOR:
      • for J in range(1, myNumber):
        • print(I,end=”*”)
      • print()
    • a.
      • RED*
      • WHITE*
      • BLACK*
      • RED*
    • b
      • YELLOW*
      • WHITE*
      • BLACK*
      • RED*
    • c
      • WHITE* WHITE*
      • YELLOW* YELLOW*
      • BLACK* BLACK*
      • RED* RED*
    • d
      • YELLOW*
      • WHITE*WHITE*
      • BLACK* BLACK* BLACK*
      • RED* RED* RED* RED* RED*
    • Ans.: b as random generates random options starting 0 to 3 and the outer loop is traversing the given list of String. So the suitable option is b only.
  11. Fill in the blank: The modem at the sender’s computer end acts as a __.
    • a. Model
    • b. Modulator
    • c. Demodulator
    • d. Convertor
    • Ans.: b. Modulator, Modem is a device that converts analog signals to digital signals. Modulation is the process of converting digital data to analog data. So the sender is sending this kind of data. Hence Modem performs the the same task.
  12. Consider the code given below:
    • b=100
    • def test(a):
      • __________________ # missing statement
      • b=b+a
      • print(a,b)
    • test(10)
    • print(b)
    • Which of the following statements should be given in the blank for #Missing Statement, if the output produced is 110?
      • a. global a
      • b. global b=100
      • c. global b
      • d. global a=100
      • Ans.: c. global b, In the given code, b is global variable hence to access value of global variable and to change the value of that variable global keyword is used
  13. State whether the following statement is True or False: An exception may be raised even if the program is syntactically correct.
    • Ans. : True, Sometimes syntax is correct but due to some input error or inappropriate datatype an exception may be raised.
  14. Which of the following statements is FALSE about keys in a relational database?
    • a. Any candidate key is eligible to become a primary key.
    • b. A primary key uniquely identifies the tuples in a relation.
    • c. A candidate key that is not a primary key is a foreign key.
    • d. A foreign key is an attribute whose value is derived from the primary key of another relation.
    • Ans.: c. A candidate key that is not a primary key is a foreign key
  15. Fill in the blank: In case of ____________________ switching, before communication starts, a dedicated path is identified between the sender and the receiver.
    • Ans.:circuit, The connection is established through a physical path between two endpoint networks.
  16. Which of the following functions changes the position of the file pointer and returns its new position?
    • a. flush()
    • b. tell()
    • c. seek()
    • d. offset()
    • Ans.: c. seek(), tell() function is used to set the cursor position and flush() is used for memory purpose.
    • Assertion(A): List is an immutable data type
    • Reasoning(R): When an attempt is made to update the value of an immutable variable, the old variable is destroyed and a new variable is created by the same name in memory.
      • (a) Both A and R are true and R is the correct explanation for A
      • (b) Both A and R are true and R is not the correct explanation for A
      • (c) A is True but R is False
      • (d) A is false but R is True
      • Ans.: (c) A is True but R is False
    • Assertion(A): Python standard library consists of number of modules.
    • Reasoning(R): A function in a module is used to simplify the code and avoids repetition.
      • (a) Both A and R are true and R is the correct explanation for A
      • (b) Both A and R are true and R is not the correct explanation for A
      • (c) A is True but R is False
      • (d) A is false but R is True
      • Ans.: (a) Both A and R are true and R is the correct explanation for A

Section B Sample Paper Computer Science Class 12 Session 2023-24

Watch this video for more practical unerstanding:

19. (i) Expand the following terms: POP3 , URL
(ii) Give one difference between XML and HTML.

Ans.:

(i) POP3: Post Office Protocol 3, URL: Uniform Resource Locator

(ii)

HTMLXML
HTML has predefined tagsNo predefined tags, user can define their own tags and use them
It focuses on WYSISYGIt focuses on structure of data
It is mainly used to display dataIt is used to transport data
It is not a case sensitiveIt is case sensitive

20. The code given below accepts a number as an argument and returns the reverse number. Observe the following code carefully and rewrite it after removing all syntax and logical errors. Underline all the corrections made.

Q -20 Sample Paper Computer Science Class 12 Session 2023-24

Ans.:

def revNumber(num):  #Error 1
  rev = 0
  rem = 0
  while num>0:       #Error 2
     rem=num%10      #Error 3
     rev=rev*10+rem
     num=num//10
  return rev         #Error 4
print(revNumber(1234))

21. Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an argument and displays the names (in uppercase) of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:”Delhi”,2:”London”,3:”Paris”,4:”New York”,5:”Doha”}
The output should be:

LONDON
NEW YORK

Ans.:

Explanation:

  1. Define a function as given the question and traverse the dictionary.
  2. In marking scheme dict.values() method is used to traverse the element individually.
  3. Then len() returns the length of the places stored in dictionary as values.
  4. In if condition(), the upper() function is used to convert the places into upper case.

Given into Marking Scheme:

PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
def countNow(PLACES):
        for place in PLACES.values():
                if len(place)>5:
                        print(place.upper())
countNow(PLACES)

Different Logic:

PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
def countNow(PLACES):
        for i in PLACES:
                if len(PLACES[i])>5:
                        print(PLACES[i].upper())
countNow(PLACES)

OR

Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing 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)

Ans.:

Explanation:

  1. The function is defined as given in the question
  2. An empty tuple is declared to store the length of values
  3. The length of each word is requried, so split() function is used to separate the words into a list object L
  4. Now list is traversed through for loop.
  5. The length of each word is stored in length variable.
  6. Now the length is contacted into a tuple
  7. Finally the tuple is returned
STR="Come let us have some fun"
def lenWords(STRING):
        T=()
        L=STRING.split()
        for i in L:
                length=len(i)
                T=T+(length,)
        return T
print(lenWords(STR))

22. Predict the output of the following code:

S="LOST"
L=[10,21,33,40]
D={}
for I in range(len(S)):
        if I%2==0:
          D[L.pop()]=S[I]
        else:
          D[L.pop()]=I+3
for K,V in D.items():
  print(K,V,sep='*')

Ans.:

Explanation:

In the above code, the string is traversed which inserts the odd-even position value from the last and assigned a key to the value from the string. Hence

33*4

40*L

21*S

10*6

23. Write the Python statement for each of the following tasks using BUILT-IN functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.

Ans.:

(i) L1.insert(2,200)

(ii) message.endswith(‘.’)

24. Ms. Shalini has just created a table named “Employee” containing columns Ename, Department, and Salary.
After creating the table, she realized that she has forgotten to add a primary key column in the table. Help her in writing an SQL command to add a primary key column EmpId of integer type to the table Employee.

Thereafter, write the command to insert the following record in the table:

EmpId- 999
Ename- Shweta
Department: Production
Salary: 26900

Ans.:

SQL Command to add primary key:
ALTER TABLE Employee ADD EmpId INTEGER PRIMARY KEY;
As the primary key is added as the last field, the command for inserting data will be:
INSERT INTO Employee VALUES(“Shweta”,”Production”,26900,999);

25. Predict the output of the following code:

Q - 25 CBSE Sample Paper Computer Science 2023-24 Class 12

Ans.:

Explanation: A and B are declared in top-level statements. When function Changer() is called first time A will take the final values of P returned by the function as follows:

Changer(A=200,B=20)

P=P/Q=A/B=200/20=10.0

Now Q=P%Q=A%B=10.0%20=10.0

So Final Values after Calling function: A=10.0, B=20, So the output for print(A,B,sep=’$’) is 10.0$20

Now again the function is called as B=Changer(B). Here B is 20 and which replaces the P and Q will be the default value 10.

Changer(B=20,A=10)

P=P/Q=B/A=20/10=2.0

Now Q=P%Q=A%B=10.0%2.0=0.0

So the final Values are A=10.0 and B=2.0. So print(A,B,sep=’$’,end=’###’) will print 10.0$2.0###

Hence the output is :

10.0$20
10.0$2.0###

Section C Sample Paper Computer Science Class 12 Session 2023-24

Watch this video for more understanding of the given questions 26 to 30.

26. Predict the output of the Python code given below:

Q-26 Sample Paper Computer Science Class 12 Session 2023-24

Ans.:

Explanation:

As per codes 0 to 9 will be converted into integers. So two digits are there 2 and 3. Then Val=Val + 1, which means 2 + 1 and 3 + 1 respectively going to be concat with Text2 Variable.

A to Z letters will be contacted with next element. So I become N, N becomes D, D becomes -. The else block will be applied to – convert it into *. Hence the output will ve

ND-*34

27. Consider the table CLUB given below and write the output of the SQL queries that follow:

CIDCNAMEAGEGENDERSPORTSPAYDOAPP
5246AMRITA35FEMALECRICKET9002006-03-27
4687SHYAM37MALECRICKET13002004-04-15
1245MEENA23FEMALEVOLLEYBALL10002007-06-18
1622AMRIT28MALEKARATE10002007-09-05
1256AMINA36FEMALECHESS11002003-08-15
1270MANJU33FEMALEKARATE12502004-04-10
2321VIRAT35MALECRICKET10502005-04-30

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;
(ii) SELECT CNAME, SPORTS FROM CLUB WHERE DOAPP<“2006-04-30” AND CNAME LIKE “%NA”;
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE GENDER = “MALE” AND PAY BETWEEN 1000 AND 1200;

ANS.:

(i)

COUNT(DISTINCT SPORTS)

——————————————

4

(ii)

CNAME SPORTS

————- ————-
AMINA CHESS

(iii)

CNAME AGE PAY

——— ——- ———-
AMRIT 28 1000
VIRAT 35 1050

28. Write a function in Python to read a text file, Alpha.txt, and displays those lines which begin with the word ‘You’.

Ans.:

Ans -28 Sample Paper Computer Science Class 12 Session 2023-24

OR

Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.

Ans.:

Ans -28 Sample Paper Computer Science Class 12 Session 2023-24

29. Consider the table Personal given below:

Table:Person

P_IDNameDesigSalaryAllowance
P01RohitManager890004800
P02KashishClerkNULL1600
P03MaheshSupervisor48000NULL
P04SahilClerk310001900
P05RavinaSuperviserNULL2100

Based on the given table, write SQL queries for the following:

  1. Increase the salary by 5% of personals whose allowance is known.
  2. Display Name and Total Salary (sum of Salary and Allowance) of all personals. The column heading ‘Total Salary’ should also be displayed.
  3. Delete the record of Supervisors who have salary greater than 25000

Ans.:

  1. update person set salary=salary+(salary*0.05) where allowance is not null;
  2. select name, ifnull(salary,0) +ifnull(allowance,0) as “Total salary” from personal;
  3. delete from personal where salary>25000 and desig=’Superviser‘;

30. A list, NList contains 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 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.

For example: If the nested list contains the following data:
NList=[[“New York”, “U.S.A.”, 11734],
[“Naypyidaw”, “Myanmar”, 3219],
[“Dubai”, “UAE”, 2194],
[“London”, “England”, 6693],
[“Gangtok”, “India”, 1580],
[“Columbo”, “Sri Lanka”, 3405]]
The stack should contain:
[‘Naypyidaw’, ‘Myanmar’],
[‘Dubai’, ‘UAE’],
[‘Columbo’, ‘Sri Lanka’]
The output should be:
[‘Columbo’, ‘Sri Lanka’]
[‘Dubai’, ‘UAE’]
[‘Naypyidaw’, ‘Myanmar’]
Stack Empty

Ans.:

NList=[["New York", "U.S.A.", 11734],
       ["Naypyidaw", "Myanmar", 3219],
       ["Dubai", "UAE", 2194],
       ["London", "England", 6693],
       ["Gangtok", "India", 1580],
       ["Columbo", "Sri Lanka", 3405]]
travel=[]
def pus_element(NList):
  for i in NList:
    if i[1]!='India' and i[2]<3500:
      travel.append([i[0],i[1]])

def pop_element():
  while len(travel):
    print(travel.pop())
  else:
    print("Stack empty")

pus_element(NList)
pop_element()

Section D Sample Paper Computer Science Class 12 Session 2023-24

31. Meticulous EduServe is an educational organization. It is planning to setup its India campus at Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA

Q- 31 Section D Sample Paper Computer Science Class 12 Session 2023-24

Block to Block distances (in Mtrs.):

FromToDistance
ADMINENGINEERING55 m
ADMINMEDIA90 m
ENGINEERINGBUSINESS55 m
ENGINEERINGMEDIA50 m
BUSINESSMEDIA45 m
DELHI HEAD OFFICECHENNAI CAMPUS2175 KM

Number of computers in each of the blocks/Center is as follows:

ADMIN110
ENGINEERING75
BUSINESS40
MEDIA12
DELHI HEAD20

a) Suggest and draw the cable layout to efficiently connect various blocks of buildings within the CHENNAI campus for connecting digital devices.
b) Which network device will be used to connect computers in each block to form a local area network?
c) Which block, in Chennai Campus should be made the server? Justify your answer.
d) Which fast and very effective wireless transmission medium should preferably be used to connect the head office at DELHI with the campus in CHENNAI?
e) Suggest a device/software to be installed in the CHENNAI Campus to take care of data security.

Ans.:

a)

Sample Paper Computer Science Class 12 Session 2023-24 Most important for practice

Explanation: The admin block has the maximum number of computers that can be set up as server room. So all blocks should be connected directly or indirectly with it. Hence the minimum distance is considered for every block and layout is prepared.

b) Switch, is a suitable device to connect every block’s computer.
c) Admin block, as it has the maximum number of computers.
d) Microwave
e) Firewall

32. (i) Differentiate between r+ and w+ file modes in Python.

Ans.:

r+ modew+ mode
Primary Functionreadingwriting
Cursor PositionBeginningBeginning
What if file not existsResults errorWhat if the file not exists

(ii) Consider a file, SPORT.DAT, containing records of the following structure:

[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the records with Sport name as “Basket Ball” to the file named BASKET.DAT. The function should return the total number of records copied to the file BASKET.DAT.

Q-32 answer CBSE Sample Paper Computer Science Class 12

OR

(Only for option ii)

A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user-defined function, findType(mtype), that accepts mtype as a parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.

Q-32 answer CBSE Sample Paper Computer Science Class 12

33.

(i) Define the term Domain with respect to RDBMS. Give one example to support your answer.
(ii) Kabir wants to write a program in Python to insert the following record in the table named Student in MYSQL database, SCHOOL:

  • rno(Roll number )- integer
  • name(Name) – string
  • DOB (Date of birth) – Date
  • Fee – float

Note the following to establish connectivity between Python and MySQL:

  • Username – root
  • Password – tiger
  • Host – localhost

The values of fields rno, name, DOB and fee has to be accepted from the user. Help Kabir to write the program in Python.

Ans.:

(i) Domain is a set of values from which an attribute can take value in each row. For example, roll no field can have only integer values and so its domain is a set of integer values.

(ii)

Sample Paper Computer Science Class 12 Session 2023-24 Most important for practice

Section E Sample Paper Computer Science Class 12 Session 2023-24

34. Consider the tables PRODUCT and BRAND given below:

Table: PRODUCT

PCodePNameUPriceRatingBID
P01Shampoo1206M03
P02Toothpaste548M02
P03Soap257M03
P04Toothpaste654M04
P05Soap385M05
P06Shampoo2456M05

Table: BRAND

BIDBNAME
M02Dant Kranti
M03Medimix
M04Pepsodent
M05Dove

Write SQL queries for the following:
(i) Display product name and brand name from the tables PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order of rating.

Ans.:

(i) SELECT PName, BName FROM PRODUCT P, BRAND B WHERE P.BID=B.BID;
(ii) DESC PRODUCT;
(iii) SELECT BName, AVG(Rating) FROM PRODUCT P, BRAND B WHERE P.BID=B.BID GROUP BY BName HAVING BName=’Medimix’ OR BName=’Dove’;

(iv) SELECT PName, UPrice, Rating FROM PRODUCT ORDER BY Rating DESC;

35.

Vedansh is a Python programmer working in a school. For the Annual Sports Event, he has created a csv file named Result.csv, to store the results of students in different sports events. The structure of Result.csv is :
[St_Id, St_Name, Game_Name, Result] – Where

  • St_Id is Student ID (integer)
  • ST_name is Student Name (string)
  • Game_Name is name of game in which student is participating(string)
  • Result is result of the game whose value can be either ‘Won’, ‘Lost’ or ‘Tie’

For efficiently maintaining data of the event, Vedansh wants to write the following user-defined functions:
Accept() – to accept a record from the user and add it to the file Result.csv. The column headings should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event.
As a Python expert, help him complete the task.

Ans.:

Sample Paper Computer Science Class 12 Session 2023-24 Most important for practice

Download Sample Papers Computer Science Class 12

This section contains various sample papers for various exams. Here we go!

Download Periodic Tests Sample Paper for Class 12 Computer Science

Follow this link to download various sample papers of periodic tests for computer science class 12.

Periodic tests Sample Paper Computer Science Class 12

Download 5 Sample Papers from the previous year

Follow this link to download sample papers published for the previous year.

Download Previous year sample papers Computer Science Class 12

Download the Latest sample paper for Computer Science Class 12

This section contains the latest sample paper for Computer Science Class 12. Download the latest sample paper for computer science class 12.

S.NoSample PaperAnswer KeyVideo
1CBSE Sample PaperDownload NowSection A
Section B
Section C
Section D
Section E
2Sample Paper 1 for Pre-board – DownloadDownload NowWatch Now

Leave a Reply