sample paper computer science2024-25, Exams of Computer science

computer science class 12 cbse sample paper

Typology: Exams

2023/2024

Available from 12/11/2024

gomathivetrivel
gomathivetrivel 🇮🇳

28 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OXALISS INTERNATIONAL SCHOOL (CBSE), THATCHUR.
Computer Science (083)
CYCLIC TEST IV (2024-25)
COMPUTATIONAL PROGRAMMING - PYTHON
Class: XII Max. Marks: 70
Date : Time : 3 Hrs.
General Instructions:
This question paper contains 37 questions.
All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
The paper is divided into 5 Sections- A, B, C, D and E.
Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
In case of MCQ, text of the correct answer should also be written.
SECTION A
Q No.
Section-A (21 x 1 = 21 Marks)
Marks
1.
Find the invalid identifier from the following:
a) None b) Name_12 c) _123num d) true
1
2.
Which of the following are random number generators ?
(a) randint() (b) randrange() (c) random() (d) All of these
1
3.
What will be the value of X in the following Python expression?
X = 2+9*((3*12)-8)/10
a) 30.0 b) 30.8 c) 28.4 d) 27.2
1
4.
In Python, ………….. defines a block of statements.
a) Block b) loop c) indentation d) { }
1
5.
What will be the output of the following code?
num = [1, 2, 3, 4, 5]
for i in range(len(num)):
num[i] *= 2
print(num)
a) [1, 2, 3, 4, 5] b) [2, 4, 6, 8, 10] c) [1, 4, 9, 16, 25] d) [2, 3, 4, 5, 6]
1
6.
What will be the output of the following code snippet? message= "Hai Python"
print(message[-2::-2])
a) iyhn b) oiyH c) otPiH d) oyi
1
7.
Assume the tuple superstore is (10,20,30,40,50), which of the following is correct
syntax for slicing operation?
a) print(superstore[0:]) b) print(superstore[:2]) c) print(superstore[:-2])
d) All of these
1
8.
What is the output of the following code?
my_dict = {"apple": 3, "banana": 2, "cherry": 5}
keys = my_dict.keys()
print(keys)
a) ["apple", "banana", "cherry"] b) ["apple"]
c) ["banana"] d) dict_keys(["apple", "banana", "cherry"])
1
pf3
pf4
pf5
pf8

Partial preview of the text

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

OXALISS INTERNATIONAL SCHOOL (CBSE), THATCHUR.

Computer Science (083)

CYCLIC TEST – IV (2024-25)

COMPUTATIONAL PROGRAMMING - PYTHON

Class: XII Max. Marks: 70

Date : Time : 3 Hrs.

General Instructions:  This question paper contains 37 questions.  All questions are compulsory. However, internal choices have been provided in some questions. Attempt only one of the choices in such questions  The paper is divided into 5 Sections- A, B, C, D and E.  Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.  Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.  Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.  Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.  Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.  All programming questions are to be answered using Python Language only.  In case of MCQ, text of the correct answer should also be written. SECTION – A Q No. Section-A (21 x 1 = 21 Marks) Marks

  1. Find the invalid identifier from the following: a) None b) Name_12 c) _123num d) true
  1. Which of the following are random number generators? (a) randint() (b) randrange() (c) random() (d) All of these
  1. What will be the value of X in the following Python expression? X = 2+9((312)-8)/ a) 30.0 b) 30.8 c) 28.4 d) 27.
  1. In Python, ………….. defines a block of statements. a) Block b) loop c) indentation d) { }
  1. What will be the output of the following code? num = [1, 2, 3, 4, 5] for i in range(len(num)): num[i] *= 2 print(num) a) [1, 2, 3, 4, 5] b) [2, 4, 6, 8, 10] c) [1, 4, 9, 16, 25] d) [2, 3, 4, 5, 6]
  1. What will be the output of the following code snippet? message= "Hai Python" print(message[-2::-2]) a) iyhn b) oiyH c) otPiH d) oyi
  1. Assume the tuple superstore is (10,20,30,40,50), which of the following is correct syntax for slicing operation? a) print(superstore[0:]) b) print(superstore[:2]) c) print(superstore[:-2]) d) All of these
  1. What is the output of the following code? my_dict = {"apple": 3, "banana": 2, "cherry": 5} keys = my_dict.keys() print(keys) a) ["apple", "banana", "cherry"] b) ["apple"] c) ["banana"] d) dict_keys(["apple", "banana", "cherry"])
  1. Given str1=”Hello” and str2=”Bye”, what is the output produced by the following expressions: (a) “Let us all say” + str (b) 3 * str1 + 4 * str
  1. Find the output: def fun3(a,b,c): return a+1,b+2,c+3 # if more than 1 values are returned than it will be as tuple t=fun3(10,20,30) print(t)
  1. (^) What will be the output of the following Python code?

def change(one, *two): print(type(two)) change(1,2,3,4) a) Integer b) Tuple c) Dictionary d) An exception is thrown

  1. A function is said to be___________ if it calls itself a. Built function b. Pre-defined function c. recursive function d. None of the above
  1. when large programs are broken down into smaller units known as……………… a. sub program b. functions c. class d. None of the above
  1. Suppose the content of a text file Notes.txt is: “ The way to get started is to quit talking and being doing” Complete the following Python code with appropriate functions to get the output as: “quit talking and being doing” F=open(“Notes.txt”) F. _______ S= F. _______ Print(S)
  1. (^) method takes a string and writes it in the file.

(a) writelines() (b) write() (c) writerow() (d) writer()

  1. (^) An interrupt or forced disruption that occurs when a program is run or executed is

termed as ………………………………… (a) Compile time error (b) Exception (c) Runtime error (d) Logical error

  1. What will be the output of the following code? def divide(x, y): try: result = x / y except ZeroDivisionError: print("Error: Division by zero") finally: print("Finally block") divide(10, 0) A) Error: Division by zero Finally block B) Finally block C) The code will raise an exception and terminate. D) None of the above.

L=[11,12,23,34,45,56,65]

Va= HowMany() OR 1+ Find the errors in the following Python code and rewrite the code after correcting errors and underline the corrected code. Def string#reverse(str1): rstr1=”” index=str1.len() while index>0; rstr1+=str1(index-1) index=index- 1 return rstr print(string_reverse(‘123abcd’))

  1. What will be the output generated by the following Python code: def fun1(m=8,n=10): global x x= y= print (m+n-x) def fun2(): x= return x print(fun2()) a,b=50, x= fun1(b) fun1() print(x)
  1. Differentiate seek() and tell() methods. 2 OR Differentiate between pickle.load() and pickle.dump() methods with suitable examples.
  1. Create a Python script that reads data from a CSV file named "input.csv" using the csv.reader(). object and prints each row of data to the console.Handle any exceptions that may occur during file handling.

OR

Write a Python code snippet to open a CSV file named "data.csv" in write mode and write a single row of data into it using the csv.writer() object.Include the necessary import statement and ensure proper closing of the file after writing.

Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. Write a user-defined function div_5(N) which accepts a list of integers in a

parameter N and pushes all those integers which are divisible by 5 from the list

N into a Stack named FactNumbers. Write function pop_div5() to pop the

topmost number from the stack and returns it. If the stack is already empty, the

function should display "Empty". Write function Disp_div5() to display all element

of the stack without deleting them. If the stack is empty, the function should

display 'None'.

For example:

If the integers input into the list VALUES are: [10, 5, 18, 35, 112]

Then the stack FactNumbers should store: [10, 5, 35]

30. A text file “Book.txt” contains a paragraph. Write a Python function that searches

for a given character and reports the number of occurrence of the character in the

file.

OR

Consider a file “Story.txt” whose content is as shown below:

Ravi has gone to his friend’s house.

His friend’s name is Rakhi.

Her house is far from his house.

Write a Python function CountHisHer() which reads the contents of the text file

“Story.txt” and counts the words His and Her (not case sensitive).

31. Consider a stack named ItemStack that contains records of items in a shop. Each

item record is represented as a list containing item_no , item _name , and

item_price.

Write the following user-defined functions in Python to perform the specified

operations on the stack ItemStack :

(I) push_item(ItemStack, new_item): This function takes the stack ItemStack and a

new item record new_item as arguments and pushes the new item record onto the

stack.

(II) pop_item(ItemStack): This function pops the topmost item record from the

stack and returns it. If the stack is already empty, the function should display

"Underflow".

(III) peep(ItemStack): This function displays the topmost element of the stack

without deleting it. If the stack is empty, the function should display 'None'.

Q No. SECTION D (4 X 4 = 16 Marks) Marks

32. i) Predict the output of the code given below:

s="Welcome2cs@JNV"

n=len(s)

m=""

for i in range(0,n):

if(s[i]>='a' and s[i]<='m'):

m+=s[i].upper()

elif(s[i]>='n' and s[i]<='z'):

m+=s[i-1]

elif(s[i].isupper()):

m+=s[i].lower()

else:

m+='&'

print("The string is: ",m)

print("The new string is: ",m[::-2])

ii) Write a Python program to remove the characters of odd index values in a string.

OR

i) Find the output of the following Python program: def makenew (mystr):

The output should be: Jerry Siddharth Underflow

b) Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing details of vehicles - {Car_Name: Maker}. The function should push the name of car manufactured by "TATA' (including all the possible cases like Tata, TaTa, etc.) to the stack. For example: If the dictionary contains the following data: Vehicle={"Santro" : "Hyundai", "Nexon": "TATA", "Safari" : "Tata"} The stack should contain Safari Nexon

35. Write a function in Python to search and display details, whose destination is

“Cochin” from binary file “Bus.dat”. Assuming the binary file is containing the

following elements in the list:

1. Bus Number

2. Bus Starting Point

3. Bus Destination

OR

Consider a binary file “Salary.dat” that has structure*Employee id, Employee

name, Salary]. Write a function countrec() in Python that would read contents of

the file “Salary.dat” and display the details of those employees whose salary is

above 20000 and less than 50000.

Q No. SECTION E (2 X 5 = 10 Marks) Marks

36. Consider the following csv file and the code fragment associated with the

following csv file :

SLNO BOOKNAME PRICE

1 Pride and Prejudice 200 2 Gone with the wind 250 3 The little Prince 170 4 Anne of Green Gables 190 5 The Giving Tree 210

import csv

f=open("c:\stud.csv")

fobj=csv.reader(f)

for k in fobj:

for j in k:

print(j, end=’’)

break

_____ # Line 1

I.What will be the output printed by the above code?

a. SLNO12345 b. SLNO c. The entire content d. Error

II. What will be the output printed by the above code if the break is replaced with

continue?

a. SLNO12345 b. SLNO c. The entire content d. Error

III. What will occur if the file stud.csv is not existing in the mentioned path?

a. It will create a new one b. It will create an error c. None of the above

d. It will cause a system reboot

IV. Which statement in the above code will help to move to the next record?

a. fobj.next() b. next(fobj) c. fobj.move() d. fobj.forward()

V. What must be written in Line 1?

a. F.close() b. f.close() c. fobj.close() d. csvfile.close()

  1. a) When do we use CSV file? b) Write a program using two functions : (i) addCustomer( ): To write Customer code, Customer name and Amt in file “cust.csv”. The details of the customers are as follows : *‘CustCode’, ‘CustName’, ‘Amount’+ *‘001’, ‘Nihir’, ‘8000’+ *‘104’, ‘Akshay’, ‘5000’+ (ii) readCustomer( ): To read the details of the customers and display them.

********************** ALL THE BEST ************************