# Class 12 Computer Science Sample Paper Term 1 With Solutions Set C

Section A

1. Which of the following is an invalid name for identifier?
(a) abckm
(b) S-num
(c) Percent
(d) _SUM

B

2. Consider the declaration a={‘a’:11,’b’:2}, which of the following represents the data type of a?
(a) List
(b) Tuple
(c) Dictionary
(d) String

C

3. Suppose L=[10,19,45,77,10,22,2], what will be the value of L[3:5]?
(a) [77,10]
(b) [45,77]
(c) [45,77,10]
(d) [77,10,22]

A

4. To open a file d:\para.txt for reading, we use ………………
(a) f = open(“d:\para.txt”, “r”)
(b) f = open(“d:\\para.txt”, “r”)
(c) f = open(file = “d:\para.txt”, “r”)
(d) f = open(file = “d:\\para.txt”, “r”)

B

5. Which operator is used to repeat the elements of the list?
(a) *
(b) +
(c) %
(d) * *

A

6. Index of ……………… refers to 4th element.
(a) 3
(b) 4
(c) 5
(d) −4

A

7. What is mean of G in LEGB rule of scope resolution?
(a) Generation
(b) Global
(c) Generate
(d) Globalisation

B

8. Suppose tuple tup1 = (56, 89, 75, 65, 99). What is the output of tup1[−3]?
(a) 65
(b) 89
(c) 75
(d) Error

C

9. What is the output of following code?
str1 =“234.4”
print(“str1”)
(a) 234
(b) 235
(c) 234.4
(d) str1

D

10. Which of the following is false about tuple?
(a) Tuple holds a sequence of heterogeneous elements.
(b) Elements of tuple are mutable.
(c) Tuples are declared in parenthesis ().
(d) Tuples store a fixed set of elements.

B

11. Identify the wrong statement.
(a) print(t1 [−3])
(b) print(max (t1))
(c) print(sum (t1))
(d) t1[−2] = 40

D

12. What will be the output of following code?
L1 = [2, 3, 4, 5]
print(len (L1))
(a) 4
(b) 3
(c) 14
(d) 5

A

13. r + is used for
(c) writing only

A

14. In complex number a + ib, ‘a’ represents as
(a) real part
(b) imaginary part
(c) special part
(d) None of these

A

15. Which of the following is a mutable data type?
(a) tuple
(b) string
(c) list
(d) None of these

C

16. Which of the following is used for standard input?
(a) sys.stdin
(b) sys.stdout
(c) sys.stderr
(d) All of these

A

17. ……………… function converts all lowercase letters into uppercase letters.
(a) lower ( )
(b) upper ( )
(c) isupper ( )
(d) islower ( )

B

18. What will be the output of Python code?
dic1 = {‘A’ : 11, ‘B’ : 2, ‘C’ : 3}
print(dic1[3])
(a) C
(b) 3
(c) {‘C’ : 3}
(d) Error

D

19. Which of the following returns a normalised absolutised version of the pathname path?
(a) getcwd ( )
(b) abspath ( )
(c) abs ( )
(d) abpath ( )

B

20. Using ……………… argument, you can declare value using name.
(a) default
(b) keyword
(c) positional
(d) friendly

B

21. Using which of the following, we can avoid rewriting the same logic/code again and again in the program?
(a) Functions
(b) Class
(c) Object
(d) Keyword

A

22. Which of the following is not included by syntax error in Python?
(a) Leaving out a keyword
(b) Incorrect indentation
(c) Empty block
(d) Division by zero

D

23. This defines the mapping data type which is used in Python.
(a) Dictionary
(b) List
(c) Tuple
(d) String

A

24. Statements that allow a program to execute a statement depending upon a given condition are called
(a) compound statements
(b) simple statements
(c) conditional statements
(d) null statements

C

25. What is the output of following code?
for i in range (−5, −7, −1) :
print(i + 1)
(a) −6
−7
(b) −6
(c) −7
(d) Error

D

Section B

26. What is the output of following code?
sum = 0
x = 4
while (x > 0) :
sum = sum + x
x = x − 1
print(sum)
(a) 4
(b) 10
(c) 7
(d) 5

B

27. What is the output of following code?
n = 5
i = 1
a = 0
b = 1
while(i<n):
print(a)
c = a+b
a = b
b = c
i = i+1

A

28. What is the output of following code?
a = 6
b = 5.5
sum = a+b
print(type(sum))
(a) class < ‘float’ >
(b) class=‘float’
(c) < class ‘float’ >
(d) < class > .< ‘float’ >

C

29. What will be the output of following code?
def myFunc (x, y) :
a = x * 2 + y − 3
print(a)
myFunc (25, 8)
(a) 50
(b) 55
(c) 175
(d) 172

B

30. Observe the following code :
myfile = open (“story.txt”, “a”)
______ # Statement 1
myfile.close( )
Fill in the blank in line marked as Statement 1 to write ‘‘Study’’ in the file ‘‘story.txt’’.
(a) myfile.write (Study)
(b) myfile.writeline (Study)
(c) myfile.write (“Study”)
(d) myfile = write (“Study”)

C

31. What is the output of following code?
def myFunc(x) :
x [2] = 45
list1 = [23, 12, 45, 72]
myFunc (list1)
print (list1)
(a) [23, 12, 45]
(b) [23, 12, 72]
(c) [45]
(d) [23, 12, 45, 72]

D

32. Evaluate the following expression and identify the correct answer.
A = 5 + 6//3 + 10*3//4 + 2 + 3//4
(a) 16
(b) 14
(c) 18
(d) 26

A

33. What is the output of following code?
def myFunc(x, y = 3) :
a = 1
for i in range (x) :
a = a * y
return a
print (f(4))
print (f(4, 4))
(a) 81
256
(b) 81
81
(c) 256
81
(d) 256
256

A

34. Suppose the content of file ‘‘story.txt’’ is What will be the output of following code?
myfile = open (“story.txt”)
print(len (r))
myfile.close( )
(a) 40
(b) 39
(c) 33
(d) 34

B

35. What will be the output of following code?
dic1 = { }
dic1[1] = 3
dic1[‘1’] = 2
dic1[1] = dic1[1] +1
sum = 0
for i in dic1 :
sum = sum + dic1 [i]
print(sum)
(a) 5
(b) 3
(c) 6
(d) 7

C

36. What will be the output of the following Python code?
a = “123456”
i = “7”
while i in a :
print(i, end = “ ”)
(a) No output
(b) 7 7 7 7 7 7 …
(c) 1 2 3 4 5 6
(d) 123456

A

37. What will be the output of the following Python code?
def myFunc(val):
val = [5]
a = [4]
myFunc(a)
print(a)
(a) [4]
(b) [5]
(c) [5, 4]
(d) [4, 5]

A

38. What will be the output of the following Python code?
a = 65
def myFunc():
global a
print(a)
a = 5
myFunc()
print(a)
(a) 65
5
(b) 65
65
(c) 5
65
(d) 5
5

A

39. What will be the output of the following Python code?
def myFunc(list1):
list1[0] = 56
x = [23, 14, 32, 99]
myFunc(x)
print(x)
(a) [56, 14, 32, 99]
(b) [56, 23, 14, 32, 99]
(c) [23, 14, 32, 99, 56]
(d) [23, 56, 14, 32, 99]

A

40. What will be the output of the following Python code?
def Func(a):
global a
a+=2
print(a)
Func(25)
print(“Arihant”)
(a) 27
Arihant
(b) Hello
(c) 27
(d) Error

D

41. Suppose the content of text file ‘‘story.txt’’ is What will be the data type of val?
myfile = open(“story.txt”, ‘r’)
myfile.close( )
(a) list
(b) string
(c) tuple
(d) sets

B

42. What is the output of the following code?
i = 0
def Func(i) :
i = i + 2
return i
Func(2)
print(i)
(a) 3
(b) 1
(c) 0
(d) Error

C

43. What is the output of the following code?
tup1 = (56, 23, ‘Mathematics’, 44, 7, ‘English’, ‘Computer’, ‘Hindi’, 9)
print(tup1[2 : 4])
(a) (23, ‘Mathematics’)
(b) (‘Mathematics’, 44)
(c) (‘Mathematics’, 44, 7)
(d) (23, ‘Mathematics’, 44)

B

44. What will be the output of the following Python code?
a = 3
for i in range(a):
a += 2
print(a)

C

45. What will be the output of the following Python code?
books = [‘Hindi’, ‘English’, ‘Computer’]
if ‘put’ in books:
print(True)
else:
print(False)
(a) True
(b) False
(c) None
(d) Error

B

46. What will be the output of the following Python code?
x = (‘Computer’,)
n = 1
for i in range(int(n)):
x = (x,)
print(x)
(a) Error, tuples are immutable
(b) ((‘Computer’,),)
(c) ((‘Computer’,)’Computer’,)
(d) ((‘Computer’,)’ Computer’,)
(((‘ Computer’,)’ Computer’,)’ Computer’,)

B

47. What will be the output of the following Python code?
for i in range(8):
if i == 4:
break
else:
print(i)
else:
print(“Terminate”)

A

48. What is the output of the following code?
def func(a = 10, b = 10):
return(a+b, a−b)
a, b = func(b = 20, a = 10)
print(a, b)
(a) 30 -10
(b) 20 0
(c) 0 10
(d) 20 10

A

49. What is the output of the following code?
count = 1
def func():
global count
for i in (1, 2, 3, 4):
count += 1
func()
print(count)
(a) 4
(b) 5
(c) 6
(d) 3

B

Section C

Case Study Based Questions

Rohan wrote a below program in which some code is missing. Answer the below questions for successfully run that program.
_____ =“ ” # Statement 1
for i in ______ : # Statement 2
str1 = ______ + str1 # Statement 3
print(“String in reverse order :”, ______ ) # Statement 4
if ( ______ ) : # Statement 5
print (“This is a palindrome string.”)
______ # Statement 6
print (“This is not a palindrome string.”)

50. Choose the correct option to fill up the blank in line marked as Statement 1.
(a) str
(b) str1
(c) i
(d) a

B

51. Choose the correct option to fill up the blank in line marked as Statement 2.
(a) string
(b) str1
(c) str
(d) string+1

A

52. Which value will be added to str1 in Statement 3?
(a) 0
(b) 1
(c) i
(d) i +1

C

53. Choose the correct option to fill up the blank in line marked as Statement 4.
(a) string
(b) str
(c) str1
(d) string +1

C

54. Choose the correct condition to be used to check palindrome the strings.
(a) string ! = str1
(b) string > = str1
(c) string < = str1
(d) string = = str1

D

55. Choose the correct option to fill up the blank in line marked as Statement 6.
(a) elif
(b) elif :
(c) else
(d) else :