NewxiiAB Cs I Miidterm 2425

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

SAMADH HIGHER SECONDARY SCHOOL

KHAJA NAGAR, TRICHY


FIRST MIDTERM EXAMINATION 2024-25
Subject : XII-AB Computer Science Time : 2:30 hrs
Subject code: 083 Maximum Marks : 50

General Instructions:

➢ This question paper contains five sections, Section A to E.


➢ All questions are compulsory.
➢ Section A have 10 questions carrying 01 mark each.
➢ Section B has 04 Very Short Answer type questions carrying 02 marks each.
➢ Section C has 03 Short Answer type questions carrying 03 marks each.
➢ Section D has 03 Long Answer type questions carrying 05 marks each.
➢ Section E has 02 questions carrying 04 marks each.
➢ All programming questions are to be answered using Python Language only

Section –A
Q No. Question Marks
1. State True or False (R)
“ converts one data type into another data type automatically in
python” (1)
2. which of the following is an invalid data type in python?(U) (1)
(a) List (b) Tuple (c) Dictionary (d) Value
3. What will the following code do? ( U)
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.
4. Consider the given expression: (U)
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
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 anu john’
(b) Type Error: Unsupported operand type(s) for ‘str’
(c) ‘My name is Anu John’
(d) ‘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
7. What will the following expression be evaluated to in python?
print(25.0/2+(4+2.0)) (A) (1)
(a) 18.75 (b) 18.0 (c) 18.5 (d) 20.0
8. Which of the following is not valid namespace? (U)
(a) Global Namespace
(1)
(b) Public Namespace
(c) Built_in Namespace
(d) Local Namespace
Q.No 9 and 10 are ASSERTION(A) AND REASONING(R) based
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 (R)
calls.
(1)
Reason (R): When you use keyword arguments in function call,
the, caller identifies the arguments by the parameter
name.
10 Assertion (A): After importing a module through import ( R) (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

SECTION – B
11. (a) predict the output of (U) (1+1)

S=”Pythonlanguag”
print(S[:-6:-2])

(b) Predict the output of

d={2:”b”,4:”c”}
d1={1:”a”}
d.update(d1)
d[1]=”v”
print(list(d.values()))

12. Write any two string operators and give examples (R) (2)
13. Predict the output of the following code? (A) (2)
def my_func(a=10,b=30):
a+=20
b-=10
return a+b,a-b

print(my_func(a=60)[0],my_func(b=40)[1])

14 Define Function and Flow of Execution (R) (1+1)


SECTION – C
15. What is the difference between a local variable and a global (3)
variable? Also, give a suitable python code illustrate both (C)
16. Trace the flow of execution for following programs: (E) (3)
1. def power(b,p):
2. r=b**p
3. return
4.
5. def calcsquare(a):
6. a=power(a,2)
7. return a
8.
9. n=5
10. result=calcsquare(n)
11. print(result)

17. How to find and write the output of the following


python code: (E)
(3)
def change(p, q=30):
p=p+q
q=p-q
print(p,“#”,q)
return p
r=150
s=100
r=change(r,s)
print(r,”#”,s)
s=change(s)

SECTION – D

18. a) What are docstrings? (U) (1+2+2)


b) How are they useful? (A)
c) Write the syntax of for statement? (A)

SECTION – E
19. Rewrite the following code in python after removing all syntax (4)
error(s). Underline each correction done in the code (A)
Value =30
for VAL in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val %5==0:
print(VAL+3)
Else
print(VAL+10)

20 a) Write the syntax of calling function and function? (A) (2+2)


b) Write the python function type? (A)

21 Find the program code given below, Identify the parts mentioned (5)
below: (CB)
def processNumber(x):
x=72
return x+3
y=54
res=processNumber(y)
identify the parts: Function header, Function call
arguments, parameters, and Function body
22. Traffic accident occur due to various reasons. While problems (5)
with roads or inadequate safety facilities lead to some accidents,
majority of the accidents are caused by drivers’ carelessness and
their failure to abide by traffic rules. (CB)
ITS Roadwork is a company that deals with manufacturing and
installation of traffic lights so as to minimize the risk of accidents.
Keeping in view the requirements, traffic simulation is to be
done.
Write a program in python that simulates a traffic light. The
program should perform the following.
(a) A user-defined function trafficLight() that accept from the
user , display an error message if the user enters anything
other the RED, YELLOW and GREEN. Function light( )
Is called and the following is displayed depending upon
return value from light():
(i) “STOP. Life is more important than speed” if the
Value returned by light() is 0.
(ii) ”PLEASE GO SLOW” if the value returned by
light() is 1.
(iii) “you may go now” if the value returned by light( ) is 2.

(b) A user-defined function light() that accepts a string as


input and returns 0 When the input is RED, 1 the input is
YELLOW and 2 when the input is GREEN. The input
should be passed as an argument.

(c) Display “BETTER LATE THAN NEVER” after the


Function trafficLight( ) is executed

You might also like