Docsity

computer science sample paper, Exams of Computer science

Toggle sidebar
bg1
CBSE
Solved Paper–2023
Computer Science
Class-12th
(Delhi & Outside Delhi Set)
Time : 3 Hours Max. Marks : 70
General Instructions:
(i) This question paper contains five sections, Section A to E.
(ii) All questions are compulsory.
(iii) Section A have 18 questions carrying 1 mark each.
(iv) Section B has 7 Very Short Answer type questions carrying 2 marks each.
(v) Section C has 5 Short Answer type questions carrying 3 marks each.
(vi) Section D has 3 Long Answer type questions carrying 5 marks each.
(vii) Section E has 2 questions carrying 4 marks each. One internal choice is given is Q.34 and 35, against Part (iii) only.
(vi) All programming questions are to be answered using Python Language only.
SECTION - A
1. State True of False.
"Identifiers are names used to identify a variable, function in a program".
2. Which of the following is a valid keyword in Python?
(a) false (b) return
(c) non_local (d) none
3. Given the following Tuple
Tup= (10, 20, 30, 50)
Which of the following statements will result in an error?
(a) print(Tup[0]) (b) Tup.insert (2,3)
(c) print(Tup[1:2]) (d) print(len(Tup))
4. Consider the given expression:
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is evaluated?
(a) True (b) False
(c) NONE (d) NULL
5. Select the correct output of the code:
S= "Amrit Mahotsav @ 75"
A=S.partition (" ")
print (A)
(a) ('Amrit Mahotsav', '@', '75') (b) ['Amrit', 'Mahotsav', '@', '75']
(c) ('Amrit', 'Mahotsav @ 75') (d) ('Amrit', '', 'Mahotsav @ 75')
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download computer science sample paper and more Exams Computer science in PDF only on Docsity!

CBSE

Solved Paper–

Computer Science

Class-

th

(Delhi & Outside Delhi Set)

Time : 3 Hours Max. Marks : 70

General Instructions:

(i) This question paper contains five sections, Section A to E. (ii) All questions are compulsory. (iii) Section A have 18 questions carrying 1 mark each. (iv) Section B has 7 Very Short Answer type questions carrying 2 marks each. (v) Section C has 5 Short Answer type questions carrying 3 marks each. (vi) Section D has 3 Long Answer type questions carrying 5 marks each. (vii) Section E has 2 questions carrying 4 marks each. One internal choice is given is Q.34 and 35 , against Part (iii) only. (vi) All programming questions are to be answered using Python Language only.

SECTION - A

1. State True of False. "Identifiers are names used to identify a variable, function in a program". 2. Which of the following is a valid keyword in Python? (a) false (b) return (c) non_local (d) none 3. Given the following Tuple Tup= (10, 20, 30, 50) Which of the following statements will result in an error? (a) print(Tup[0]) (b) Tup.insert (2,3) (c) print(Tup[1:2]) (d) print(len(Tup)) 4. Consider the given expression: 5<10 and 12>7 or not 7> Which of the following will be the correct output, if the given expression is evaluated? (a) True (b) False (c) NONE (d) NULL 5. Select the correct output of the code: S= "Amrit Mahotsav @ 75" A=S.partition (" ") print (A) (a) ('Amrit Mahotsav', '@', '75') (b) ['Amrit', 'Mahotsav', '@', '75'] (c) ('Amrit', 'Mahotsav @ 75') (d) ('Amrit', '', 'Mahotsav @ 75')

14 Oswaal CBSE Question Bank Chapterwise & Topicwise,^ Computer Science , Class-XII

6. Which of the following mode keeps the file offset position at the end of the file? (a) r+ (b) r (c) w (d) a 7. Fill in the blank. .............. function is used to arrange the elements of a list in ascending order. (a) sort() (b) arrange() (c) ascending() (d) asort() 8. Which of the following operators will return either True or False? (a) += (b) != (c) = (d) = 9. Which of the following statement(s) would give an error after executing the following code? stud={"Murugan":100, "Mithu":95} # Statement 1 print (stud[95]) # Statement 2 Stud ["Murugan"]=99 # Statement 3 print(Stud.pop()) # Statement 4 print(Stud) # Statement 5 (a) Statement 2 (b) Statement 3 (c) Statement 4 (d) Statement 2 and 4 10. Fill in the blank. ............. is a number of tuples in a relation. (a) Attribute (b) Degree (c) Domain (d) Cardinality 11. The syntax of seek() is: file_object.seek(offset[,reference_point]) What is the default value of reference_point? (a) 0 (b) 1 (c) 2 (d) 3 12. Fill in the blank: .............. clause is used with SELECT statement to display data in a sorted form with respect to a specified column. (a) WHERE (b) ORDER BY (c) HAVING (d) DISTINCT 13. Fill in blank: .............. is used for point-to-point communication or unicast communication such as radar and satellite. (a) INFRARED WAVES (b) BLUETOOTH (c) MICROWAVES (d) RADIOWAVES 14. What will the following expression be evaluated to in Python? print(4+35/3–5%2) (a) 8.5 (b) 8. (c) 10.2 (d) 10. 15. Which function returns the sum of all elements of a list? (a) count() (b) sum() (c) total() (d) add() 16. Fetchall() method fetches all rows in a result set and returns a: (a) Tuple of lists (b) List of tuples (c) List of strings (d) Tuple of strings Q.17 and 18 are ASSERTION (A) and REASONING (R) based questions. Mark the correct choice as (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.

16 Oswaal CBSE Question Bank Chapterwise & Topicwise,^ Computer Science , Class-XII

25. (a) Differentiate between CHAR and VARCHAR data types in SQL with appropriate example. OR (b) Name any two DDL and any two DML commands.

SECTION - C

26. (a) Consider the following tables – LOAN and BORROWER: Table: LOAN LOAN_NO B_NAME AMOUNT L-170 DELHI 3000 L-230 KANPUR 4000 Table: BORROWER CUST_NAME LOAN_NO JOHN L- KRISH L- RAVYA L- How many rows and columns will be there in the natural join of these two tables? OR (b) Write the output of the queries (i) to (iv) based on the table, WORKER given below: TABLE: WORKER W_ID F_NAME L_NAME CITY STATE 102 SAHIL KHAN KANPUR UTTAR PRADESH 104 SAMEER PARIKH ROOP NAGAR PUNJAB 105 MARY JONES DELHI DELHI 106 MAHIR SHARMA SONIPAT HARYANA 107 ATHARVA BHARDWAJ DELHI DELHI 108 VEDA SHARMA KANPUR UTTAR PRADESH (i) SELECT F_NAME, CITY FROM WORKER ORDER BY STATE DESC; (ii) SELECT DISTINCT (CITY) FROM WORKER; (iii) SELECT F_NAME, STATE FORM WORKER WHERE L_NAME LIKE '_HA%; (iv) SELECT CITY, COUNT(*) FORM WORKER GROUP BY CITY; 27. (a) Write the definition of a Python function named LongLines() which reads the contents of a text file named 'LINES.TXT' and displays those lines from the file which have at least 10 words in it. For example, if the content of 'LINES.TXT' is as follows: Once upon a time, there was a woodcutter He lived in a little house in a beautiful, green wood. One day, he was merrily chopping some wood. He saw a little girl skipping through the woods, whistling happily. The girl was followed by a big gray wolf. Then the function should display output as: He lives in a little house in a beautiful, green wood. He saw a little girl skipping through the woods, whistling happily. OR (b) Write a function count_Dwords() in Python to count the words ending with a digit in a text file "Details. txt". Example: If the file content is as follows:

Solved Paper-2023 17

On seat2 VIP1 will sit and On seat1 VVIP2 will be sitting Output will be: Number of words ending with a digit are 4

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations COMPUTER and SALES given below: Table: COMPUTER PROD_ID PROD_NAME PRICE COMPANY TYPE P001 MOUSE 200 LOGITECH INPUT P002 LASER PRINTER 4000 CANON OUTPUT P003 KEYBOARD 500 LOGITECH INPUT P004 JOYSTICK 1000 IBALL INPUT P005 SPEAKER 1200 CREATIVE OUTPUT P006 DESKJET PRINTER 4300 CANON OUTPUT Table: SALES PROD_ID QTY_SOLD QUARTER P002 4 1 P003 2 2 P001 3 2 P004 2 1 (i) SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER; (ii) SELECT COMPANY, COUNT(*) FROM COMPUTER GROUP BY COMPANY HAVING COUNT(COMPANY) > 1; (iii) SELECT PROD_NAME, QTY_SOLD FROM COMPUTER C, SALES S WHERE C.PROD_ID=S. PROD_ ID AND TYPE = 'INPUT'; (iv) SELECT PROUD_NAME, COMPANY, QUARTER FORM COMPUTER C, SALES S WHERE C.PROD_ ID=S.PROD_ID; (b) Write the command to view all databases. 29. Write a functions EOReplace() in Python, which accepts a list L of numbers. Thereafter, it increments all even numbers by 1 and decrements all odd numbers by 1. Example: If Sample Input data of the list is: L=(10,20,30,40,35,55) Output will be: L=(11,21,31,41,34,54) 30. (a) A list contains following record of customer. [Customer_name, Room Type] Write the following user defined functions to perform given operations on the stack name 'Hotel': (i) Push_Cust() – To Push customer' names of those customers who are staying in 'Delux' Room Type. (ii) Pop_Cust() – To Pop the names of customers from the stack and display them. Also, display "Underflow" when there are no customers in the stack. For example: IF the lists with customer details are as follows: ["Siddarth", "Delux"] ["Rahul", "Standard"] ["Jerry", "Delux"] The stack should contain Jerry Siddharth The output should be: Jerry Siddharth Underflow

Solved Paper-2023 19

for i in range(1,3): first=random.randint(2,5)– sec=random.randint(3,6)– third=random.randint(1,4) print(M[first],M[sec],M[third],sep="#") (i) 10#25# 20#25# (ii) 5#25# 25#20# (iii) 30#20# 20#25# (iv) 10#15#25# 15#20#10# (b) The code given below deletes the record from the table employee which contains the following record structure: E_code - String E_name - String Sal - Integer City - String Note the following to establish connectivity between Python and MySQL:

  • Username is root
  • Password is root
  • The table exists in a MySQL database named emp
  • The details (E_code,E_name,Sal,City)are the attributes of the table. Write the following statements to complete the code: Statement 1 – to import the desired library. Statement 2 – to execute the command that deletes the record with E_code as 'E101'. Statement 3 – to delete the record permanently from the database. import ____________ as mysql #Statement 1 def delete() : mydb=mysql.connect(host="localhost",user="root", passwd="root",database="emp") mycursor=mydb.cursor() ____________ # Statement 2 ____________ # Statement 3 print ("Record deleted") OR (a) Predict the output of the code given below: def makenew(mystr): newstr=" " count= for i in mystr: if count%2!=0: newstr=newstr+str(count) else: if i.lower(): newstr=newstr+i.upper() else: newstr=newstr+i count+= print(newstr) makenew("No@1") (b) The code given below reads the following records from the table employee and displays only those records who have employees coming from city 'Delhi': E_code - String

20 Oswaal CBSE Question Bank Chapterwise & Topicwise,^ Computer Science , Class-XII

E_name - String Sal - Integer City - String Note the following to establish connectivity between Python and MySQL:

  • Username is root
  • Password is root
  • The table exists in a MySQL database named emp.
  • The details (E_code,E_name,Sal,(City))are the attributes of the table. Write the following statements to complete the code: Statement 1 – to import the desired library. Statement 2 – to execute the query that fetches records of the employees coming from city 'Delhi'. Statement 3 – to read the complete data of the query (rows whose city is Delhi) into the object named details, from the table employee in the database. import ___________ as mysql # Statement 1 def display() : mydb=mysql.connect(host="localhost",user="root", passwd="root",database="emp") mycursor=mydb.cursor() ___________ # Statement 2 details = ___________ # Statement 3 for i in details: print (i) 33. (a) Write one difference between CSV and text files. Write a program in Python that defines and calls the following user defined functions: (i) COURIER_ADD(): It takes the values from the user and adds the details to a csv file 'courier.csv'. Each record consists of a list with field elements as cid, s_name, Source, destination to store Courier ID, Sender name, Source and destination address respectively. (ii) COURIER_SEARCH() : Takes the destination as the input and displays all the courier records going to that destination. OR (b) Why is important to close a file before exiting? Write a program in Python that defines and calls the following user defined functions: (i) Add_Book() : Takes the details of the books and adds them to a csv file 'Book.csv'. Each record consists of a list with field elements as book_ID, B_name and pub to store book ID, book name and publisher respectively. (ii) Search_Book() : Takes publisher name as input and counts and displays number of books published by them.

SECTION - E

34. The school has asked their estate manager Mr. Rahul to maintain the data of all the labs in a table LAB. Rahul has created a table and entered data of 5 labs. LABNO LAB_NAME INCHARGE CAPACITY FLOOR L001 CHEMISTRY Daisy 20 I L002 BIOLOGY Venky 20 II L003 MATH Preeti 15 I L004 LANGUAGE Daisy 36 III L005 COMPUTER Mary Kom 37 II Based on the data given above answer the following questions: (i) Identify the columns which can be considered as Candidate keys. (ii) Write the degree and cardinality of the table. (iii) Write the statements to: (a) Insert a new row with appropriate data. (b) Increase the capacity of all the labs by 10 students which are on 'I' Floor.

22 Oswaal CBSE Question Bank Chapterwise & Topicwise,^ Computer Science , Class-XII

ANSWERS Delhi Set-I 64/5/

SECTION - A

1. True. Explanation: Identifiers are names given to parts of a program – variables, functions. 2. Option (b) is correct. Explanation: false is a Boolean data and non_local is not a keyword. 3. Option (b) is correct. Explanation: Tuples are immutable and insert method will not work on them. 4. Option (a) is correct. Explanation: 5<10 and 12>7 or not 7> True and True or not True True and True or False True or False True 5. Option (d) is correct. Explanation: The partition() method searches the first occurrence of the specified string,and splits the string into a tuple containing three elements. In question specified string is " " (space) so, - The first element contains the part before the specified string (space). - The second element contains the specified string (space). - The third element contains the part after the specified string (space). 6. Option (d) is correct. Explanation: Append-only mode (a) is used to insert the text at the end of the file. When the file is opened in append mode in Python, the handle is positioned at the end of the file. 7. Option (a) is correct. Explanation: The sort() function of a list arranges the elements in ascending order. 8. Option (b) is correct. Explanation: Not equal to compares two values and returns a Boolean indicating whether the two values are not equal or equal. 9. Option (d) is correct. Explanation: Statement 2 : 95 is not a key of the dictionary. Statement 4 : pop() method requires the key of the item to be popped. 10. Option (d) is correct. Explanation: The number of rows/tuples in a relation is called cardinality of the table. 11. Option (a) is correct. Explanation: By default reference point is 0 , that is the beginning of the file. 12. Option (b) is correct. Explanation: The order by clause can be used to arrange the data of a table in a specific order. 13. Option (c) is correct. Explanation: Microwaves are used for point to point or unicast communication. 14. Option (b) is correct. Explanation: (4 + 3 * 5/3 – 5% 2) 4 + 15/3 – 5% 2 4 + 5.0 – 5% 2 4 + 5.0 – 1

15. Option (b) is correct. Explanation: The sum() function returns the sum of all elements of a list. 16. Option (b) is correct. Explanation: The fetchall() function fetches all the records of the table and returns a list comprising tuples, each representing a record. 17. Option (a) is correct. Explanation: To use a function the respective module must be imported. The import statement can be written anywhere before using the function. 18. Option (a) is correct. Explanation: Stack follows the Last-In –First – Out approach.

SECTION - B

19. Errors in code def max_num(L): max=L(0) for a in L: if a>max max=a return max Corrected code def max_num(L): max=L[0] for a in L: if a>max: max=a return max 20. (a) Wired transmission Wireless transmission 1. Physical cables are required. 1. No physical cables. Transmission through air. 2. Maintenance and repair is difficult and costly. 2. Maintenance is easier. 3. Not harmful to health. 3. Harmful for health. 4. Not effected by weather effects. 4. Affected by weather conditions. 5. Not so suitable for long distance transmission. 5. Suitable for long distance transmission.

Solved Paper-2023 23

OR

(b)

Uniform Resource Locator (URL)

Domain Name

If you want to find a particular website, URL is best for it because a URL is a complete web address to find a particular website.

The main motive of the domain name is to make it easier to access a website. They are more used as a brand and are usually referred to as a brand name. URL is a string that represents the complete web address of any web page.

A domain name is a human-friendly text form of the IP address.

It is the string that represents a complete web address that contains the domain name.

It is the part of the URL that is more human friendly.

It also contains the following parts- method, protocol, hostname, port, and path of the file.

It contains three parts- Top Level Domain, Intermediate Level, and the Low Level. Example: In the URL 'https://cloudflare.com/ learning/', 'cloudflare.com' is the domain name

21. (a) Output: [“Rajat”,”Rajan”,”Ashish”] Explanation: Listofnames [–1 : –4 : –1] returns elements from index –1 to –3 decrementing by –1. (b) Output: 1 Explanation: tupl.index(20) returns the index of the 1st occurrence of 20 in the tuple. 22. All the candidate keys that are not primary key are referred to as Alternate key. Example: Consider the table student as per following structure : Table : Student Roll Name Phone Aadhar Marks In the student table : Candidate keys : Roll, Phone, Aadhar If Primary key is : Roll Alternate keys : Aadhar, Phone 23. (a) Full forms: HTML : Hypertext Markup Language TCP : Transmission Control Protocol (b) In networking, a protocol is a set of rules for formatting and processing data. Network protocols are like a common language for computers. The computers within a network may use vastly different software and hardware, however, the use of protocols enables them to communicate with each other regardless. 24. (a) ['CSCS','HINDIHINDI', 'PHYSICSPHYSICS', 'CHEMISTRYCHEMISTRY','MATHSMATHS'] Explanation: The code iterates through the elements of the list and modifies the list with element + element , if the number of elements in the list is >4. Here the list contains 5 elements, so each element is replicated by 2 in all positions.

OR

(b) Output: 65#70@ Explanation: The call() function checks the value of global a. Since a is 30 and 30 %2 gives 0 in both the function calls , the statement x+=a executes, that gives the values 30 + 35 and 30 + 40 in the respective calls.

25. (a) CHAR VARCHAR CHAR is Used to store strings of fixed size.

VARCHAR is Used to store strings of variable length. Its range in size from 1 to 8000 bytes.

Its range in size from 1 to 8000 bytes.

It Uses a fixed amount of storage, based on the size of the column.

It Uses varying amounts of storage space based on the size of the string stored. It takes up 1 to 4 byte for each character, based on collation setting.

It takes up 1 to 4 byte for each character based on collation and requires one or more bytes to store the length of the data. Better performance. Slightly poorer performance because length has to be accounted for. Example: Consider the table student given below : Table : Student Roll Name Phone Aadhar Marks If the user uses char(30) for the Name field every value will occupy 30 characters, irrespective of whether the name stored is “Ria” or “Ramakrishnan Ayyar”. Instead if varchar(30) is used , for “Ria” it will occupy 3 units , whereas for “Ramakrishnan Ayyar” , 18 units will be occupied. OR (b) DDL : Create , Alter DML : Update , Delete

SECTION - C

26. (a) Rows : 2 Columns : 4 Explanation: In a natural join the common field is not repeated, and only common row of same field will be display. (b) (i) F_Name City SAHIL KANPUR VEDA KANPUR SAMEER ROOP NAGAR MAHIR SONIPAT MARY DELHI ATHARVA DELHI

Solved Paper-2023 25

(iv) WAN : Wide area network. Since the distance is 300KM ,the network formed is a WAN. (v) FTP : File transfer protocol The File transfer protocjol can be used for transferring (Uploading and downloading) files.

32. (a) (i) 10#25# 20#25# Explanation: The randint (x, y) returns a random value between x and y inclusive of x and y. Here all the three calls to the randint() function return random values between index 1 to 4 of the list M. (b) Statement 1: mysql.connector Statement 2: mycursor.execute(”Delete from employee where E_code=’E101’”) Statement 3: mydb.commit() OR (a) N1@ Explanation: The function makenew() iterates through each of the characters of the string passed and creates a new string comprising of uppercases of the string characters and the values of count or the original characters depending on the values of count and cases of the characters in the string. (b) Statement 1: mysql.connector Statement 2: mycursor.execute(”Select

  • from employee where city=’Delhi’”) Statement 3: mycursor.fetachall() 33. (a) Difference between csv file and text file .txt File: This is a plain text file which can be opened using a notepad present on all desktop PCs running MS Windows, any version. You can store any type of text in this file. There is no limitation of what so ever text format. .csv File: abreviation of "comma seperated values" This is a special file extension commonly used by MS Excel. Basically this is also a plain text file but with a limitation of comma seperated values. Normally when you double click this type of file it will open in MS Excel. If you do not have MS Excel installed on your computer or you find Notepad easy to use then you also can open this file in a notepad by right clicking the file and from the menu select "Open With" and then choose notepad. import csv def COURIER_ADD(): cid=”” sname=”” src=”” dest=”” f = o p e n ( " c o u r i e r. csv","w",newline=") courierwriter=csv.writer(f) ans='y' courierrec=[] while ans=='y': cid=input("Enter courier id :") sname=input("Enter sender name :")

src= input("Enter source :") dest= input("Enter destination :") rec=( cid,sname, src,dest) courierrec.append(rec) ans=input("Continue(y/n)") courierwriter.writerows(courierrec) f.close() def COURIER_SEARCH(): d=”” ds=”” ds=input(“Enter destination to search :”) with open("courier csv","r",newline='') as fh: creader=csv.reader(fh) for rec in creader: d=str(rec[3]) if d==ds: print(rec) fh.close() COURIER_ADD() COURIER_SEARCH() OR (b) Files are limited resources managed by the operating system, making sure files are closed after use will protect against hard-to-debug issues like running out of file handles or experiencing corrupted data. Python doesn't flush the buffer, that is, write data to the file, until it's sure you're done writing, and one way to do this is to close the file. If you write to a file without closing, the data won't make it to the target file. import csv def Add_Book(): bid=”” bname=”” pub=”” f = o p e n ( " B o o k. csv","w",newline='') bookwriter=csv.writer(f) ans='y' bookrec=[] while ans=='y': bid=input("Enter book id :") bname=input("Enter book name :") pub= input("Enter publisher :") rec=( bid,bname, pub) bookrec.append(rec) ans=input("Continue(y/n)") bookwriter.writerows(bookrec) f.close() def Search_Book(): count= pub=”” p=”” pub=input(“Enter publisher name to search :”) with open("Book.csv","r",newline='') as fh: breader=csv.reader(fh) for rec in breader:

26 Oswaal CBSE Question Bank Chapterwise & Topicwise,^ Computer Science , Class-XII

p=str(rec[2]) if p==pub: count+= print(“No. of books published by “,pub,”=”,count) fh.close()

34. (i) Candidate key : LABNO (ii) Degree : 5 , Cardinality : 5 (iii) (a) Insert into LAB values(“L006”,”Physics”,”Jo hn”,40,”III”); (b) Update LAB set capacity=capacity + 10 where Floor=”I”;

OR

(iii) (a) Alter table LAB ADD CONSTRAINT Primary Key(LABNO); (b) Drop table LAB;

35. Statement 1: open(“Cust_file.dat”,”wb”) Statement 2: qty<10: Statement 3: pickle.dump(c_detail,bin_file) Statement 4: break OR (iii) Statement 5: bin_file.close() Statement 6: write_bin()