0% found this document useful (0 votes)
51 views7 pages

G-12 CSC 20%-1 - Marking Scheme

This document outlines a marking scheme for a Computer Science revision test for Class XII, covering various topics in Python programming. It includes multiple-choice questions, assertions, evaluations, and coding tasks, along with sections for explanations and error corrections. The test is structured into sections with different types of questions, totaling a maximum of 70 marks.

Uploaded by

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

G-12 CSC 20%-1 - Marking Scheme

This document outlines a marking scheme for a Computer Science revision test for Class XII, covering various topics in Python programming. It includes multiple-choice questions, assertions, evaluations, and coding tasks, along with sections for explanations and error corrections. The test is structured into sections with different types of questions, totaling a maximum of 70 marks.

Uploaded by

Kishorre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Revision Test - 20% – I

Computer Science (083) – Marking Scheme


DATE: MAXIMUM MARKS: 70
CLASS: XII DURATION: 180 Minutes

SECTION – A (18x1=18)
1. Which of these is not a core data type?
a) Lists b) Dictionary c) Tuples d) Class
2. How would you write xyin Python as an expression?
a) x^y b) x**y c) x^^y d) None of these
3. Identify the valid arithmetic operator in Python from the following:
a) ? b) < c) ** d) and
4. What is the value of x? x = int (13.25+4/2)
a) 17 b) 14 c) 15 d) 23
5. Which two operators can be used on numeric values in Python?
a) @ b) % c) + d) #
6. Which of the following four code fragments will yield following output?
Eina
Mina
Dika
Select all of the function calls that result in this output
a) print (‘ ‘ ‘Eina b) print (‘ ‘ ‘EinaMinaDika ‘ ‘ ‘)
\nMina
\nDika‘ ‘ ‘)
c) print (‘Eina\nMina\nDika’) d) print (‘Eina
Mina
Dika’)
7. Which of the following is an invalid datatype in Python?
a) Set b) None c) Integer d) Real
8. Which of the following is the correct output for the execution of the following Python statement?
Print (5 + 3 **2/2)
a) 32 b) 8.0 c) 9.5 d) 32.0
9. For a given declaration in Python as s=” WELCOME”, which of the following will be the correct output
of print (E (1::2])?
a) WEL b) COME c) WLOE d) ECM
10. The keys of a dictionary must be of ____________ types.
a) integer b) mutable c) immutable d) any of these
11. What data type is the object below?
L = [1, 23, ‘hello’, 1]
a) list b) dictionary c) array d) tuple
12. To store values in terms of key and value, what core data type does Python provide?
a) list b) tuple c) class d) dictionary
13. What is the value of the expression? 3 + 3.00, 3**3.0
a) (6.0, 27.0) b) (6.0, 9.00) c) (6, 27) d) [6.0, 27.0] e) [6, 27]
14. Which is the correct form of declaration of dictionary?
a) Day = {1:’monday’, 2:’tuesday’, 3:’wednesday’}
b) Day = (1;’monday’, 2;’tuesday’, 3;’wednesday’)
c) Day = [1:’monday’, 2:’tuesday’, 3:’wednesday’]
d) Day = {1’monday’, 2’tuesday’, 3’wednesday’}
15. You have the following code segment:
String1 = “my”
String2 = “work”
print (String1 + String2.upper()). What is the output of the code?
a) mywork b) MY Work c) myWORK d) My Work
16. Which line of code produces an error?
a) “one” + ‘two’ b) 1 + 2 c) “one” + “2” d) ‘1’ + 2
In the following questions, a statement of Assertion (A) is followed by a statement of Reason (R). Mark
the correct choice as:
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false (or partly true).
d) A is false (or partly true) but R is true.
e) Both A and R are false or not fully true.
17. Assertion (A): Lists and Tuples are similar sequence types of Python, yet they are two different data
types. (a)
Reason (R): List sequences are mutable and Tuple sequences are immutable.
18. Assertion (A): “””A Sample Python String””” is a valid Python String.
Reason (R): Triple Quotation marks are not valid in Python. (c)

SECTION – B (7x2=14)
19. Evaluate the following expressions:
a) 6 * 3 + 4 **2 // 5 – 8 - 13 b) 10 > 5 and 7 > 12 or not 18 > 3 - False
20. What do you understand by the term Iteration?
Answer: Iteration refers to repetition of a set of statements for a sequence of values or as
long as a condition is true.
21. Predict the outputs of the following programs:
i) for z in range (-500, 500, 100):
print (z)
Ans: -500 -400 -300 -200 -100 0 100 200 300 400
ii) x = “apple, pear, peach”
y = x. split (“,”)
for z in y:
print (z)
Ans: apple
pear
peach
22. i) Find and write the output of the following python code:
x = “abcdef”
i = “a”
while i in x:
print (i, end=” “)
Ans: aaaaaa--- infinite or endless loop
ii) Given the lists L = [1, 3, 6, 82, 5, 7, 11, 92], write the output of print (L[2:5]).
Ans: [6, 82, 5]
23. What is the length of the tuple shown below?
T = ((((‘a’, 1), ‘b’, ‘c’), ‘d’, 2), ‘e’, 3)
Length of the tuple is 3
t1 = ‘a’, 1
t2 = t1, ‘b’, ‘c’
t3 = t2, ‘d’, 2
t4 = t3, ‘e’, 3
24. Rewrite the adjacent code in python after removing all syntax error(s). Underline each correction done
in the code:
30 = To
for k in range (0, To)
IF k % 4 = = 0:
print (K * 4)
Else:
Print (K + 3)
Ans:To = 30 # 30 should be in Rvalue and To should be in Lvalue
for k in range (0, To): # colon missing
if k % 4 = = 0: # if should be in lowercase
print (K * 4)
else: # else ‘E’ should be in lowercase
print (K + 3)
25. Name the function/method required to
i) check if a string contains only uppercase letters. isupper ()
ii) gives the total length of the list. len ()
SECTION – C (5x3=15)
26. How many times will the following for loop executes and what’s the output?
i) for i in range(-1, 7, -2): ii) for i in range (1, 3, 1):
for j in range(3): for j in range (i + 1):
print (1, j) print(‘*’)
i) The loops execute 0 times and the code produces no output.
ii) The loop executes 5 times as * * * * *
27. What is the difference between a keyword and an identifier?
Keyword is a special word that has a special meaning and purpose. Keywords are reserved and
are a few. Example: if, elif, else etc. are keywords.
Identifier is the user-defined name given to a part of a program viz., variable, object, function
etc. identifiers are not reserved. These are defined by the user but they can have letters, digits and a
symbol underscore. For instance, _chk, chess, trial etc. are identifiers in Python.
28. How are dictionaries different from lists?
The dictionary is similar to lists in the sense that it is also a collection of data-items just like lists
But, it is different from lists in the sense that lists are sequential collections (ordered) and dictionaries
are non-sequential (unordered)
29. Predict the output of the following code snippet:
a) arr = [1, 2, 3, 4, 5, 6]
for i in range (1,6):
arr[i – 1] = arr[i]
for i in range (0, 6):
print (arr[i], end = “ “)
Answer: 2, 3, 4, 5, 6, 6
b) Numbers = [9, 18. 27, 36]
for Num in Numbers:
for N in range (1, Num%8):
print (N, ‘#’, end=” “)
print ()
Answer: 1 #
1#2#
1 # 2 # 3#
c) my_dict = {}
my_dict [(1, 2, 4)] = 8
my_dict [(4, 2, 1)] = 10
my_dict [(1, 2)] = 12
sum = 0
for k in my_dict:
sum + = my_dict [k]
print (sum)
print (my_dict)
Answer: 30{(1, 2, 4) : 8, (4, 2, 1) : 10, (1, 2) : 12}
30. Write a method in python to display the elements of list thrice if it is a number and display the element
terminated with ‘#’. If it is not a number.
For example, if the content of list is as follows:
List = [‘41’, ‘DROND’, ‘GIRIRAJ’, ‘13’, ‘ZARA’]
The output should be
414141
DROND#
GIRIRAJ#
131313
ZARA#
Answer: def display (my_list):
for item in my_list:
if item.isdigit():
print (item * 3)
else:
print (item + ‘#’)
display ()
SECTION – D (2x4(2+1+1) =8)
31. a) Rao has written a code to input a number and check whether it is prime or not. His code is having
errors. Rewrite the correct code and underline the corrections made.
def prime ():
n = int(input(“Enter number to check::”) # bracket is missing
for i in range (2, n//2):
if n % i= 0: # wrong equality operator
print(“Number is not prime\n”)
break # wrong indent
else:
print (“Number is prime\n’) # quotes mismatch
b) value = 30
for VAL in range (0, Value) # colon is missing
If val % 4 == 0: # If should be in lowercase
print (VAL * 4)
Elseif val % 5 == 0: # it should be elif
print (VAL + 3)
else # colon is missing
print (VAL + 10)
32. a) Find the errors. State the reasons:
i) t = [1, “a”, 9.2]
t [0] = 6
There are no errors in this python code. Lists in python can contain elements of any type. As lists
are mutable so t[0] = 6 is also valid.
ii) t = ‘hello’
t [0] = “H”
t[0] = "H" will raise an error because strings in python are immutable, meaning we cannot change
individual characters in a string after it has been created. Therefore, attempting to assign a new
value to t[0] will result in an error.
iii) t = [1, “a”, 9.2]
t [4] = 6
t [4] = 6 will raise an error as we are trying to change the value at index 4 but it is outside the
current range of the list t. As t has 3 elements so its indexes are 0, 1, 2 only.

iv) for Name in [Amar, Shveta, Parag]


IF Name [0] = ‘S’:
Print (Name)
The errors in this code are:
1. In the list [Amar, Shveta, Parag], each element should be enclosed in quotes because they are
strings.
2. The equality comparison operator is '==' instead of = for checking equality.
3. if statement should be lowercase
b) Write a program that reads a string and checks whether it is a palindrome string or not
string = input (“Enter a string:”)
length = len (string)
mid = length / 2
rev = -1
for a in range (mid):
if string [a] = = string [rev]:
a+=1
rev-=1
else:
print (string, “is not a palindrome”)
break
else:
print (string, “is a palindrome”)
SECTION – E (3x5=15)
33. Explain Tokens and its types with suitable examples.
The smallest individual unit in a program is known as Token or a lexical unit.
Types:
i) Keywords ii) Identifiers (Names) iii) Literals iv) Operators
v) Punctuators
Keywords:
A keyword is a word having special meaning reserved programming language.
Example: false, assert, del, for, in, or, while, None, break, elif, from, is, pass, with, True, class, else,
global, lambda, raise, yield, and, continue, except, if, nonlocal, return, as, def, finally, import, not,
try
Identifiers:
Identifiers are the names given to different parts of the program viz., variables, objects, classes,
functions, lists, dictionaries, and so forth.
Valid Identifiers:
Myfile, MYFILE, _CHK, Z2T0Z9, DATE9_7_77, _DS, FILE13, _HJI3_JK
Invalid Identifiers:
DATA-REC, 29CLCT, break, My.file

Literals:
Literals are the data items that have a fixed / constant value.
Python allows several kinds of literals:
i) String Literals: It is a sequence of characters surrounded by quotes. (single or double or triple
quotes)
Single line strings
Multiline strings
Example:
>>> Text1 = “Hello World” - Single line string
>>> Text2 = “Hello\ - Multiline string
World”
>>> Text3 = ‘ ‘ ‘ Hello - No backslash needed
World ‘ ‘ ‘
ii) Numeric Literals: Numeric literals are numeric values. They are:
int, floating point, complex number.
iii) Boolean Literals:A Boolean literal in Python is used to represent one of the two Boolean
values. i.e., True or False
iv) Special Literal None: Python has one special literal, which is None. The None literal is used
to indicate absence of value.
Operators:
Operators are tokens that trigger some computation / action when applied to variables and
other objects in an expression.
The operators can be arithmetic, relational, bitwise, identity, assignment, membership
operator, arithmetic-assignment, logical operators.
Punctuators:
Punctuators are symbols that are used in programming languages to organize sentence
structures, and indicate the rhythm and emphasis of expressions, statements, and program structure
Common punctuators of Python programming language are:
‘ “ # () [] {} @ , : . ‘ =
34. a) Write a program that asks the user to input number of seconds and then expresses it in terms of many
minutes and seconds it contains.
Solution:
numseconds = input (“Enter number of seconds”)
numseconds_int = int (numseconds)
numminutes = numseconds_int//60
remainingseconds = numseconds_int % 60
print (‘minutes:’, numminutes)
print (‘seconds:’, remainingseconds)
b) Consider the given expression: not True and False or True
Which of the following will be correct output if the given expression is evaluated?
i) True ii) False iii) NONE iv) NULL
c) Find and write the output of the following python code:
for Name in [‘Jay’, ‘Riya’, ‘Tanu’, ‘Anil’]:
print (Name)
if Name [0] == ‘T’:
break
else:
print (‘Finished!’)
print (‘Got it!’)
Solution:
Jay
Finished!
Riya
Finished!
Tanu
Got it!
35. a) What is the difference between a list and a tuple?

List Tuple

Lists are mutable sequences of Tuples are immutable sequences of


Python i.e., we can change elements Python i.e., we cannot change elements of
of a list in place. a tuple in place.

The syntax to create list is <list- The syntax to create tuple is <tuple-
name> = [value,.....] name> = (value, ....)

Lists cannot be used as keys in


Tuples can be used as keys in dictionary.
dictionary.

Lists cannot be used as elements of a


Tuples can be used as elements of a set.
set.

Lists are slower compared to tuples. Tuples are faster compared to lists.

b) Write the most appropriate list method to perform the following tasks:
i) Delete a given element from the list. - remove ()
rd
ii) Delete 3 element from the list. - pop ()
iii) Add an element in the end of the list. - append ()
iv) Add an element in the beginning of the list. - insert ()
v) Add element of a list in the end of a list. - extend ()

You might also like