Computer Science Examination Questions for Class 12, Exams of Computer science

Computer Science – Class 12 - Question Paper – 35 Questions – 8 pages – 1 2 3 4 & 5 marks Questions – All Programming Questions are to be answered using Python language only – Helpful for Students appearing Board Examination and Teachers

Typology: Exams

2024/2025

Available from 09/09/2024

kbzone1973
kbzone1973 🇮🇳

244 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CHENNAI SAHODAYA SCHOOLS COMPLEX
Page 1 of 8
COMMON EXAMINATION-2024
Class-12
(COMPUTER SCIENCE 083)
Roll No.: Maximum Marks:70
Date: / / Time allowed: 3 hours
SECTION A
1
s="hello"
print(s.index('a'))
in the above code what will be the exception that is thrown ?
1
2
Which of the following is the valid variable name?
(a) f %2 (b) 20ans (c) ans (d) $ans
1
3
Given tp = (1,2,3,4,5,6). Which of the following two statements will give the same output?
1. print(tp[:-1]) 3.print(tp[0:5])
2. print(tp[0:4]) 4. print(tp[-4:])
(a) Statement 1 and 2 (b)Statement 2 and 4
(c ) Statement 1 and 4 (d)Statement 1 and 3
1
4
l=[0,True,False,1]
l.sort(reverse=1)
print(l)
1
5
Select the correct output of the code:
Str=“Computer”
Str=Str[-4:]
print(Str*2)
a. Uter b. uterretu c.uteruter d.None of these
1
6
Name the file attribute to check whether the file is closed or not ?
1
7
Fill in the blank
command is used to modify the attribute datatype or size in a table structure.
1
8
The following SQL is which type of join:
select customer.cust_id,order.cust_id,name, order_id from customer, order;
1
9
Fill in the blank:
constraint is used to restrict entries in other table’s non key attribute, whose values
are not existing in the primary key of reference table.
10
Identify the error in the following code rectify the same and predict the output?
print(round(sum((30.678,),[1,2,3,]),2))
1
(General Instructions)
Please check that this question paper contains 8 printed pages.
Please check that this question paper contains 35questions.
Please write down the serial number of the question before attempting it.
Reading time of 15 minutes is given to read the question paper alone. No writing during this time.
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A has 18 questions carrying 01 mark each.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
Section C has 05 Short Answer type questions carrying 03 marks each.
Section D has 02 Long Answer type questions carrying 04 marks each.
Section E has 03 questions carrying 05 marks each. One internal choice is
given
All programming questions are to be answered using Python Language only.
pf3
pf4
pf5
pf8

Partial preview of the text

Download Computer Science Examination Questions for Class 12 and more Exams Computer science in PDF only on Docsity!

COMMON EXAMINATION- 2024

Class- 12

(COMPUTER SCIENCE 083)

Roll No.: Maximum Marks: 70

Date: / / Time allowed: 3 hours

SECTION A

1 s="hello" print(s.index('a')) in the above code what will be the exception that is thrown?

2 Which of the following is the valid variable name? (a) f %2 (b) 20ans (c) ans (d) $ans

3 Given tp = (1,2,3,4,5,6). Which of the following two statements will give the same output?

  1. print(tp[:-1]) 3.print(tp[0:5])
  2. print(tp[0:4]) 4. print(tp[-4:]) (a) Statement 1 and 2 (b)Statement 2 and 4 (c ) Statement 1 and 4 (d)Statement 1 and 3

4 l=[0,True,False,1] l.sort(reverse=1) print(l)

5 Select^ the^ correct^ output^ of^ the^ code: Str=“Computer” Str=Str[-4:] print(Str*2) a. Uter b. uterretu c.uteruter d.None of these

6 Name the file attribute to check whether the file is closed or not? 1 7 Fill in the blank command is used to modify the attribute datatype or size in a table structure.

8 The^ following^ SQL^ is^ which^ type^ of^ join: select customer.cust_id,order.cust_id,name, order_id from customer, order;

9 Fill in the blank: constraint is used to restrict entries in other table’s non key attribute, whose values are not existing in the primary key of reference table. 10 Identify^ the error^ in^ the^ following^ code rectify the same and predict the output? print(round(sum((30.678,),[1,2,3,]),2))

(General Instructions)  Please check that this question paper contains 8 printed pages.  Please check that this question paper contains 35questions.  Please write down the serial number of the question before attempting it.  Reading time of 15 minutes is given to read the question paper alone. No writing during this time.  This question paper contains five sections, Section A to E.  All questions are compulsory.  Section A has 18 questions carrying 01 mark each.  Section B has 07 Very Short Answer type questions carrying 02 marks each.  Section C has 05 Short Answer type questions carrying 03 marks each.  Section D has 02 Long Answer type questions carrying 04 marks each.  Section E has 03 questions carrying 05 marks each. One internal choice is given  All programming questions are to be answered using Python Language only.

11 A^ text^ file^ student.txt^ is^ stored^ in^ the^ storage^ device.^ Identify^ the^ correct^ option^ out^ of^ the following options to open the file in read mode. i. myfile = open('student.txt','rb') ii. myfile = open('student.txt','w') iii. myfile = open('student.txt','r') iv. myfile = open('student.txt') a) only (i) b) both (i) and (iv ) c) both (iii) and (iv) d) both (i) and (iii)

12 Fill in the blank: A database is a special control structure that facilitates the row by row processing of records in the resultset. (a) fetch b)table c) cursor d)query

13 Fill in the Blank is the networking device that connects computers in a network by using packet switching to receive, and forward data to the destination.

14 Predict the output of the following code l=['1','2','3'] m=str(l) print(m) print(m.find('2'))

15 The language used in application programs to request data from the DBMS is referred to as the -------------------.

16 To create a connection between MYSQL database and Python application connect() function is used. Which of the following are mandatory arguments required to connect any database from Python. a) Username, Password, Hostname, Database Name, Port b) Username, Password, Hostname c) Username, Password, Hostname, Database Name d) Username, Password, Hostname, Port

Q17 and 18 are ASSERTION AND REASONING 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 17 Assertion^ (A):-^ All^ the^ keyword^ arguments^ passed^ must^ match^ one^ of^ the^ arguments^ accepted^ by the function Reasoning (R):- You cannot change the order of appearance of the keyword.

18 Assertion^ (A): CSV^ file^ is^ a^ human^ readable^ text^ file^ where^ each^ line^ has^ a^ number^ of^ fields, separated by commas or some other delimiter. Reason (R): writerow() function can be used for writing into writer object.

SECTION B

Amit is trying to write a program to find the factorial of a number passed to the function and he has written the following code but it’s not working and producing errors. Help Amit to correct this and rewrite the corrected code. Also underline the corrections made. Def fact(num): factorial = 1 if num < 0: print("Sorry, factorial does not exist for negative numbers") else num == 0 print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num,"is",factorial)

20 Write two points of difference between Switch and Router. OR Write two points of difference between star topology and bus topology

i) SELECT PName, Average (UPrice) FROM Product GROUP BY Pname; ii) SELECT DISTINCT Manufacturer FROM Product; iii) SELECT COUNT (DISTINCT PName) FROM Product; iv) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName; 27 Write^ a^ function^ countwords()^ in^ Python^ that^ counts^ the^ number^ of^ words^ containing^ digits^ in^ it present in a text file “myfile.txt”. Example: If the “myfile.txt” contents are as follows: This is my 1st class on Computer Science. There are 100 years in a Century. Student1 is present in the front of the line. The output of the function should be: 3 OR Write a function countwords() in Python, which should count the occurrences of word ‘me’ and ‘my’ in the text file ‘myfile.txt’. Example: If the “myfile.txt” contents are as follows: “I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave,' as you call yourself! Keep the third piece of wisdom for your own use, and let me have the gold.” The output of the function should be: No of words ‘my’ is 2 No. of Words ‘me’ is 1

28 Define^ a^ function^ SWAP (SCORES)^ to^ swap^ all^ those^ values^ in^ the^ list^ of^ SCORES, which are alternate elements. For example: If the SCORES contain [200, 456, 300, 100, 234, 678] The output should be displayed as 300 200 100 456 678 234

29 Consider the table Personal^ given below: Table: Personal P_ID Name Desig Salary Allowance P01 Rohit Manager 89000 4800 P02 Kashish Clerk NULL 1600 P03 Mahesh Supervisor 48000 NULL P04 Salil Clerk 31000 1900 P05 Ravina Supervisor NULL 2100 Based on the given table, write SQL queries for the following: i) Increase the salary by 5% of personals whose allowance is known. ii) Display Name and Total Salary (sum of Salary and Allowance) of all personals. The column heading ‘Total Salary’ should also be displayed. iii) Delete the record of personals who have salary greater than 25000

30 A^ list contains following record of a student: [Rno, Name, Dob, Class] Write the following user defined functions to perform given operations on the stack named ‘status’: (i) Push_element() - To Push a record of student to the stack (ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack Empty” when there are no elements in the stack. OR Write a function in Python, Push(book) where, book is a dictionary containing the details of a book in form of {bookno : price}. The function should push the book in the stack whose price is greater than 300. Also display the number of elements pushed into the stack. For example: If the dictionary contains the following data: Dbook={"Python":350,"Hindi":200,"English":270,"Physics":600, “Chemistry”:550} The stack should contain Chemistry Physics Python The output should be: The count of elements in the stack is 3

SECTION D

31 a) Predict the output from the following table: FOOD COMPANY i) SELECT FOODS.ITEM_ID, FOOD.ITEM_NAME, COMPANY.COMPANY_ID, COMPANY.COMPANY_NAME FROM FOODS, COMPANY WHERE FOODS.COMPANY_ID=COMPANY.COMPANY_ID; ii) SELECT * FROM Foods NATURAL JOIN Company b) Given below are the tables for a database Events: Table: Student RollNo Name Class Event_Id 1101 Roshan XII XII_ 1102 Mohan XI XI_ 1103 Robin XII XII_ 1104 Meena XII XII_ 1105 Kanti XI XI_ Table: Event EventCode EName Event_Date E- 1010 IT-quiz 12/01/ E- 1011 GruopDebate 12/01/ E- 1012 Programming 15/01/ E- 1013 TechToday 16/01/ E- 1014 DreamTech 16/01/ E- 1015 IT-Presentaion 15/01/ ITEM_ID ITEM_NAME^ COMPANY_ ID 1 Chex Mix 16 6 Cheez-It 15 2 BN Biscuit 15 4 Pot Rice 15 COMPANY_ID COMPANY_NAME 15 Jack Hill 16 Akas Foods 17 Foodies 19 sip-n-Bite 4

e. Suggest the most suitable (very high speed) service to provide data connectivity between Admission Building located in Delhi and the campus located in parampur. 34 a) Predict the output of the following code: def div5(n): if n%5==0: return n* else: return n+ def output(m=5): for i in range(0,m): print(div5(i),'@',end='',sep=',') print('') output(7) output() output(3) b) The code given below inserts the following record in the table Employee: Empno – integer EName- String Desig– String Salary– integer Note the following to establish connectivity between Python and MYSQL:  Username is root Password is Password  The table exists in a MYSQL database named Bank.  The details (Empno, Ename, Design and Salary) are to be accepted from the user. Write the following missing statements to complete the code: Statement 1 – to form the cursor object Statement 2 – to query string. Statement 3 - to execute insert query for employee table Statement 4- to incorporate the changes done to the employee table import mysql.connector mydb=mysql.connector.connect(host='localhost',user='root',passwd='Password',database='bank') mycursor= ___________________ # statement eno=int(input('enter Employee no')) nm=input('enter Employee name') d=input('enter Designation) s=int(input(‘Enter salary’)) rtup=(eno,n,d,s) rq=’’’insert into Employee (Empno, Ename, Design,Salary) values ( )’’’#statement mycursor _________________ #statement 3 mydb.-----------#statement print("Data Added successfully")

35 a.^ i)What^ is^ the^ use^ of^ tell()^ function? For which operation of binary file tell() is mostly used. ii)Write the mode by which the file pointer can be moved in both direction. Write the syntax of seek(). b. Write a program in Python that defines and calls the following user defined functions: i) Add(): To add the record of a student to a binary file “record.dat”. Each record should be with field elements [admno,sname,class] ii) Count(): To count the number of students studying in class xii and also display those student name starts with the letter ‘A’ OR a. Give a difference between dump and load function also write the syntax of both the functions. b. Write a program in Python that defines and calls the following user defined functions: i. Add(): To add the record of an animal to a binary file “animal.dat”. Each record should be with field elements [animal name, animal type, animal food] ii. Search(): To search and copy all the animal names who eat grass as their food to an another file animal1.dat

END OF PAPER