0% found this document useful (0 votes)
11 views9 pages

Class 12 Cs Pt1 Exam Paper1

The document is a pre-board examination paper for Class XII Computer Science at Kendriya Vidyalaya KV1 Agra, consisting of multiple-choice questions and coding tasks. It covers various topics in Python programming, including data types, functions, loops, and exception handling. The exam is designed to assess students' understanding and application of computer science concepts, with a total of 40 marks allocated.

Uploaded by

Mridul Maurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views9 pages

Class 12 Cs Pt1 Exam Paper1

The document is a pre-board examination paper for Class XII Computer Science at Kendriya Vidyalaya KV1 Agra, consisting of multiple-choice questions and coding tasks. It covers various topics in Python programming, including data types, functions, loops, and exception handling. The exam is designed to assess students' understanding and application of computer science concepts, with a total of 40 marks allocated.

Uploaded by

Mridul Maurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

KENDRIYA VIDYALAYA KV1 AGRA

PRE BOARD EXAMINATION (TERM-I)


Class: XII CS
Section – A Time Allowed: 90 Minutes
Subject: (083) Computer Science Maximum Marks: 40

MARKS
1 1
Which of the following statement is incorrect?
A. X=*Y
B. My_name = ’Deepesh’
C. While = 400
D. None of these

2 Consider a declaration L = (35) 1


Which of the following represents the datatype of L?
A. Tuple
B. List
C. Integer
D. Dictionary

3 1
What will be the output of the following code
segment?
Lst=['KV', 'is', 'the', 'best', 'school', 'in', 'India']
print(Lst[ : : 4])
A. [‘KV’, ‘is’,’the’,’best’]
B. [‘KV’, ‘best’, ‘India’]
C. ['KV', 'School']
D. [‘KV’, ‘is’,’the’, ‘best’,’school’]
4 1
Which of the following is a Python tuple?
A. (11, ‘is’, ‘my’, ‘class’)
B. {11, ‘is’, ‘my’, ‘class’}
C. (11, is, ‘my’, ‘class’]
D. {}

5 1
Which of the following is not used to repeat some
code in Python?
A. for loop
B. do-while loop
C. while loop
D. None of the above.

6 1
The _________ statement terminates the execution
of the whole loop.
A. continue
B. break
C. breake
D. exit

7 1
Which of the following is/are features of list?
A. List is mutable
B. List is a sequence data type.
C. List[: : -1] prints reverse of the list
D. All of the above

8 Which of the following functions will return 1


the key, value pairs of a dictionary?
A. keys()
B. values()
C. items()
D. all of these

9 Write full form of csv: 1


A. Comma settled values
B. Common separated values
C. Comma separated values
D. None of the above

10 Alankar wants to check whether her name is listed 1


in list.dat or not. Which command he can write to
open the file:
A. a=open(“list.dat”,”rb”)
B. with open (“list.dat’,’rb”) as a:
C. None
D. Both a and b

11 Choose correct answer 1


t=['Marks', 'of', 'Yash', [34, 43, 41, 38]]
print(t[: : -1])
A. [[38, 41, 43, 34], 'Yash', 'of', 'Marks']
B. [[34, 43, 41, 38], 'Yash', 'of', 'Marks']
C. [[38, 41, 43, 34], 'hsaY', 'fo', 'skraM']
D. [[83, 14, 34, 43], 'hsaY', 'fo', 'skraM']

12 #Predict the output of the following code: 1


def myFunc(n1, n2):
for x in range(n1, n2):
if n1%x==0:
print(x, end=' ')
myFunc(10, 20)

A. 10 12 14 16 18 20
B. 12 16 20
C. 10 20
D. 10

13 Which of the following is not a python functions 1


type:
A. Module function
B. User-defined function
C. Random function
D. Built-in-function

14 Which statements are true about the blocks in 1


exception handling?
A. Exception is raised in try
B. Exception is handled in except
C. The statements written within finally block are
always executed regardless of whether an exception
occurred in try block or not.
D. All of these

15 Which of the following statement opens a binary file 1


record.bin in write mode and writes data from a list
lst1 = [1, 2, 3] on the binary file?
A. with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)
B. with open('record.bin','wb') as myfile:
pickle.dump(myfile,lst1)
C. with open('record.bin','rb') as myfile:
pickle.dump(myfile,lst1)
D. with open('record.bin','ab') as myfile:
pickle.dump(myfile,lst1)
16 Find output of the following code: 2
for I in range (15, 9, -2):
print (I, end=’ ‘)
A. 15 13 11
B. 15 13 11 9
C. 15 14 13 12 11 10 9
D. 15 14 13 12 11 10
17 What will be the output of the following code 2
segment?
l=list(range(100,20,-20))
print(l)

A. [100, 80, 60, 40]


B. [100, 80, 60, 40]
C. [100, 20, -20]
D. Error
18 #Consider the following code and choose correct 2
answer:
def nameage(name, age):
return [age, name]
t=nameage("Kanak Sharma", 20)
print(t)

A. tuple
B. list
C. [20, 'Kanak Sharma']
D. string

'''
19 #What is the output of the program given below? 2
def myFunc(x):
L=[k for k in range(0, x ,2)]
print(L*2)
myFunc(5)
'''
OUTPUT
A. [ 0, 2, 4, 0, 2, 4 ]
B. [ 0, 4, 8 ]
C. Both A and B
D. Error because we cannot multiply List

'''
20 #Find the output of the following code: 2
L1=[25,65,85,47]
L2=(L1)
L1[2]=100
print(L1,'\t',L2)

'''
OUTPUT

A. [25, 65, 100, 47] [25, 65, 85, 47]


B. [25, 65, 85, 47] [25, 65, 85, 47]
C. [25, 65, 100, 47] [25, 65, 100, 47]
D. [25, 65, 85, 47] [25, 65, 100, 47]
'''
21 #Consider the code given below and identify how 3
many times the
#message “all the best” will be printed
def prog(name):
for x in name:
if x.isalpha():
print('alphabet')
elif x.isdigit():
print('digit')
elif x.isupper():
print('upper')
else:
print('all the best')
prog('[email protected]')
22 ‘’’Write a Python program having following functions 4
:
1. A function with the following signature :
remove_letter(sentence, letter)
This function should take a string and a letter (as a
single-character string) as arguments, returning a
copy of that string with every instance of the
indicated letter removed. For example,
remove_letter("Hello there!", "e") should return the
string "Hllo thr!".
Try implementing it using <str>.split() function.
2. Write a function to do the following :
Try implementing the capwords() functionality using
other functions, i.e., split(), capitalize() and join().
Compare the result with the capwords() function's
result.
'''

def remove_letter(sentence, letter):


words = sentence.split()
new_sentence = []
for word in words:
new_word = ''
for char in word:
if char.lower() != letter.lower():
new_word += char
new_sentence.append(new_word)
return ' '.join(new_sentence)

def capwords_custom(sentence):
words = sentence.split()
capitalized_words = []
for word in words:
capitalized_word = word.capitalize()
capitalized_words.append(capitalized_word)
return ' '.join(capitalized_words)
sentence = input("Enter a sentence: ")
letter = input("Enter a letter: ")
print("After removing letter:",
remove_letter(sentence, letter))

from string import capwords


sentences_input = input("Enter a sentence: ")
sentences = sentences_input.split('.')

for sentence in sentences:


sentence = sentence.strip()
print("Custom capwords
result:",capwords_custom(sentence))
print("Capwords result from string module:",
capwords(sentence))
23 #consider the following code 4

import math
import random
print(str(int(math.pow(random.randint(2,4),
2))),end=' ')
print(str(int(math.pow(random.randint(2,4),
2))),end=' ')
print(str(int(math.pow(random.randint(2,4),
2))),end=' ')
'''
24 ‘’’What are the possible outcoms(s) executed from 4
the following code?
Also specify the maximum and minimum values that
can be assigned to
variable PICKER'''

import random
PICK=random.randint(0,3)
CITY=['DELHI', 'AGRA', 'MATHURA','MUMBAI']
for I in CITY:
for J in range(1, PICK):
print(I, end=' ')
print()

You might also like