0% found this document useful (0 votes)
69 views5 pages

newxiiAB Cs I Miidterm 2425ans

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)
69 views5 pages

newxiiAB Cs I Miidterm 2425ans

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
You are on page 1/ 5

SAMADH HIGHER SECONDARY SCHOOL

KHAJA NAGAR, TRICHY


FIRST MIDTERM EXAMINATION 2024-25
Subject : XII-A&B Computer Science Time : 2:30 hrs
Subject code: 083 ANSWER KEY Maximum Marks : 50

SECTION –A
Q No. Question Marks
1. State True or False
“ converts one data type into another data type automatically in
python” (1)
Ans. TRUE
2. Which of the following is an invalid data type in python? (1)
(a) List (b) Tuple (c) Dictionary (d) Value
Ans. (d) Value
3. What will the following code do?
dict={“phy”:94,”che:70,”Bio”:82,”Eng”:95}
dict.update((“che”:72,”Bio”:80))
(a) It will create new dictionary as
dict={che”:72,”Bio”:80} and old dict will be deleted

(b) It will throw and error ad dictionary cannot be updated


(c) It will simply update the dictionary as
dict={“phy”:94,”che”:72,”Bio”:80,”Eng”:95}
(1)
(d) It will not throw any error but it will not do any changes
in dict.

Ans. (c) It will simply update the dictionary as


dict={“phy”:94,”che”:72,”Bio”:80,”Eng”:95}
4. Consider the given expression:
True and False or True and not True
Which of following will be correct output if the given
expression is evaluated?
(a) True
(b) False (1)
(c) NONE
(d) NULL

Ans. (b) False


5. Select the correct output of the following string operation ?
str="my name is Anu John" (A) (1)
print(str.capitalize( ))
(a) ‘My name is anujaohn’
(b) Type Error: Unsupported operand type(s) for ‘str’
(c) ‘My name is Anu John’
(d) ‘My Name is Anu john’
Ans. (a) ‘My name is anu john’
6 Which of the following statement(s) would give an error after (1)
executing the following code? (A)

for i in range(10): #Statement 1


if(i==5) #Statement 2
break: #Statement 3
else: #Statement 4
print(i) #Statement 5
(a) Statement 3
(b) Statement 2
(c) Statement 4
(d) Statement 2 and 3

Ans. (d) Statement 2 and 3


7. What will the following expression be evaluated to in
python? (1)
print(25.0/2+(4+2.0))
(a) 18.75 (b) 18.0 (c) 18.5 (d) 20.0
Ans. (c) 18.5
8. Which of the following is not valid namespace?
(a) Global Namespace
(1)
(b) Public Namespace
(c) Built_in Namespace
(d) Local Namespace

Ans. (b) Public Namespace

Q.No 9 and 1O are ASSERTION(A) AND REASONING(R) based (1)


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 correct explanation
for A
(c) A is true but R is false
(d) A is false but R is True

9. Assertion (A): key wore arguments are related to the function


calls.

Reason (R): When you use keyword arguments in function call,


the, caller identifies the arguments by the parameter name.

Ans. (a) Both A and R are true and R is the correct


explanation for A.

10 Assertion(A): After importing a module through import (1)


statement, all its function definitions , variables, constant etc are
made available in the market
Reason(R): import module definition do not become part of the
program name spaces if imported through an import <module>
statement

Ans. (b) Both A and R are true and R is not correct


explanation for A

SECTION – B
11. (a) gun (1+1)
(b) ['b', 'c', 'v']
12. The + operator create a new string by joining the two operand (2)
strings e.g ., “power “+”ful” will result into ‘powerful’
(ii) To use a * operator with string and number i.e number *
string or string* number . the new string number of repeation of
the sring operand e.g 3 * ”hai” will return ‘haihaihai’
13. 100 0 (2)
14 (i) A function is a subprogram that acts on data and often (1+1)
returns a value
(ii) The Flow of Execution refers to the order in which
statements are executed during a program run.
SECTION – C
15. Local variable: (3)
1, It is a variable which is declared within a function or within
a block
2. It is accessible only within a function/block in which is
declared

Global variable:
1. It is variable which is declared outside all the function
2. It is accessible throughout the program

def cube(n):
cn=n*n*n
return
x=10
xcubed=cube(x)
print(x,”cubed is”, xcubed)
16. 1→5→9→10→5→6→1→2→3→6→7→10→11 (3)
17. 250 # 150 (3)
250 # 100
130 # 100
SECTION – D
18. a) A docstring is just a regular python triple –quoted string that
is the first thing in a function body/a module/a class

b) when executing a function body(or a module/class) the


docstring doesn’t do anything like other comments, but python
stores it as part of the function documentation. using help()
function.

c) for <variable> in <sequence>:


statements_to_repeat

SECTION – E
19. Corrected code: (4)
Value =30
for VAL in range(0,Value):#error1 colon missing
If val%4==0: #error2 if should be in lower case
print (VAL*4)
elif val %5==0:#error3 it should be elif
print(VAL+3)
else: #error4 e lowercase and colon missing
print(VAL+10)
20. a) <function-name>(value-to-be-passed-to-argument>) (2+2)
def <function name> ([parameters]):
[“ “ “<function’s docstring>” “ “]
<statement>
[<statement>]
:
b) 1. Built-in functions
2. Functions defined in modules
3. User defined functions

21. Function header: def processNumber(x): (5)


Function call l: processNumber(y)
Arguments : y
Parameters : x
Function Body : x=72
return x+3
22. def trafficLight(): (5)
signal=input(“Enter the colour of the traffic light..”)
if (signal not in(“RED”,”YELLOW”,”GREEN”)):
print(“please enter a valid Traffic light colour in
capitals”)
else:
value=light(signal)
if (value==0):
print(“STOP. Life is more important than speed”)
elif (value==1):
print(”PLEASE GO SLOW”)
else:
print(“you may go now”)

def light(color):
if (color==”RED”):
return (0)
elif (color==”YELLOW”):
return (1)
else:L return (2)

trafficLight( )
print(“BETTER LATE THAN NEVER” )

You might also like