Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

Rev 1 _ q With Ans _python Basics and Flow Control 17.08.24

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Rev 1 _ q With Ans _python Basics and Flow Control 17.08.24

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Pushpathur, Palani – 624 618

Class: XII Session: 2023-24


Computer Science (083) – Revision Test 01
Maximum Marks: 70 Time Allowed: 3
Hrs

General Instructions:

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


2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each.
8.All programming questions are to be answered using Python Language only.

SECTION A 18 X 1 = 18 Marks

1. Find the valid identifier from the following 1


a. 2_Myname b. My name c. True d. Myname_2
Answer is:d
2. Which of the following operator can be used with string data type? 1
a. ** b. % c. + d. /
Answer is:c
3. Which of the following symbol is used in Python for Multiline comments line 1
comment?
a. /*** b. /* c.’’’ d. #
Answer is:c
4. Which of the following properly expresses the precedence of operators (using 1
parentheses) in the following expression: 5*3 > 10 and 4+6==11
a. ((5*3) > 10) and ((4+6) == 11) b.(5*(3 > 10)) and (4 + (6 == 11))
c. ((((5*3) > 10) and 4)+6) == 11 d.((5*3) > (10 and (4+6))) == 11
Answer is : a
5. Python identifiers are case sensitive. 1

a. True b. False c.Depends on


Program d.Depends on the computer system

Answer is : a
6. If you want to display the values without decimal place after division, which of the 1
following symbol is used?

a. / b. // c. % d. **

Answer is : b
7. 1. Which of the is a correct statement? 1

a) xyz = 10 100 1000


b) x y z = 10 100 1000
c) x, y, z = 10, 100, 1000
d) x y z= 10, 100, 1000

Answer : c
8. 1
Which of the following is not a keyword?
a) Eval b) assert c) nonlocal d) pass

Answer : a)

9. What is the order of precedence in python? 1


(i) Parentheses ii) Exponential iii) Multiplication iv) Division v) Addition vi)
Subtraction
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v

Answer : a
10 3. What will be the value of X in the following Python expression?
X = 2+9*((3*12)-8)/10
a) 30.0 b) 30.8 c) 28.4 d) 27.2

Answer : d

11 Which of the following can be used as valid variable identifier(s) in Python?


a) total b) 7Salute c) Que$tion d) global

Answer : a

12 Which of the following statement is correct for an AND operator?


a) Python only evaluates the second argument if the first one is False
b) Python only evaluates the second argument if the first one is True
c) Python only evaluates True if any one argument is True
d) Python only evaluates False if any one argument is False

Answer : b

13 The step argument in range() function


.
a. indicates the beginning of the sequence
b. indicates the end of the sequence
c. indicates the difference between every two consecutive numbers in the sequence
d. generates numbers up to a specified value

Answer : c
14 T=(“See You”) What is the data type of T?
a)tuple b)string c)List d)set

Answer : b
15 Assertion(A):An identifier may be combination of letters and numbers.
Reason(R):No special symbols are permitted in an identifier name
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 the correct explanation for A
c)A is True but R is False

d)A is False but R is True

Answer : C
16 Which of the following is not considered a valid identifier in Python:
a) three3
b) _main
c) hello_kv1
d) 2 thousand

Answer : d

17 Which of the following is the mutable data type in python:


a) int
b) string
c) tuple
d) list

Answer : d

18 Which of the following statement converts a tuple into a list in Python:


a) len(string)
b) list(tuple)
c) tup(list)
d) dict(string)

Answer: b

SECTION – B [ 7 X 2 = 14 Marks ]
19. Give the output of the following when num1 = 4, num2 = 3, num3 = 2 2

a) num1 += num2 + num3


print (num1)

Ans :9
b) num1 = num1 ** (num2 + num3)
print (num1)
Ans : 1024

c)num1 **= num2 + num3


Ans :66

d) num1 = '5' + '5'


print(num1)
Ans : 55

Ans : a) 9 b)
20 In how many ways, can you work in Python? What is the difference between them? 2

Ans-In two ways we can work in Python- (i) Interactive mode (ii) Script Mode
In interactive mode, one command can run at a time and commands are not
saved. Whereas in Script mode, we can save all the commands in the form of a
program file and can see output of all lines together.
21 How many types of sequences are supported in Python? List with 2
examples.
Ans: Three Types of Sequences are supported in python: (i) String (ii) List (iii)
Tuple
22 Give the output of the following 2
Sum = 0
for k in range(5):
Sum = Sum+k
print(Sum)
Ans : 10
23 Give the output of the following 2
Sum = 0
for k in
range(10 , 1, -2):
Sum = Sum+k
print(Sum)

Ans : 30
24 Give the output of the following 2
for k in range(4):
for j in range(k):
print(‘*’, end = ‘ ‘)
print()

Ans :
*
**
***
25 Write the ouput of the following code:- 2
Text = "gmail@com"
L=len(Text)
Ntext=""
for i in range(0,L):
if Text[i].isupper():
Ntext=Ntext+Text[i].lower()
elif Text[i].isalpha():
Ntext= Ntext+Text[i].upper()
else:
Ntext=Ntext+'bb'
print(Ntext)

Ans :
GMAILbbCOM

SECTION – C [ 5 X 3 = 15 Marks ]
26 Define Data Type. Explain mutable and immutable objects in python with 3
examples.

Answer :

27 Find the output of the following: 3


A) x=5+3*4/2-5+(3*2) Ans : 12.0
B) y=a**b+c(d-a) where a=2,b=3,c=5,d=3 Ans : 13
C) (3-10**2+99/11) Ans : -88

28 Rewrite the following code in python after removing all syntax error(s). Underline 3
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)
29 Rewrite the following code after removing all syntax error(s) and underline each 3
correction done:
Runs=(10,5,0,2,4,3)
for I in Runs:
if I=0:
print(Maiden Over)
else:
print(Not Maiden)
30 Write the python program to print the index of the character in a string. 3

Example of string : “pythonProgram”


Expected output:
Current character p position at 0
Current character y position at 1
Current character t position at 2

Answer :
string1 = input("enter string")
for i in range(len(string1)):
print("current character",string1[i],"position at",i)

SECTION – D [ 3 X 5 = 15 Marks ]
31 What do you mean by Debugging? Explain it’s categories. 5
32 What is the use of else statement in for loop and in while loop ? Explain. 5

Answer :
Else with loop is used with both while and for loop. The else block is executed at the
end of loop means when the given loop condition is false then the else block is
executed.
i=0
while i<5:
i+=1
print("i =",i)
else:
print("else block is executed")
Explanation
 declare i=0
 we know then while loop is active until the given condition is true. and we check
i<5 it’s true till the value of i is 4.
 i+=1 increment of i because we don’t want to execute the while loop infinite
times.
 print the value of i
 else block execute when the value of i is 5.

l = [1, 2, 3, 4, 5]
for a in l: print(a)
else:
print("else block is executed")
Explanation
 declare a list l=[1,2,3,4,5]
 for loop print a.
 else block is execute when the for loop is read last element of list.

33 Differentiate between type conversion and type casting in python 5


with examples.
Answer :
Type Conversion
In type conversion, the python interpreter automatically converts one data type to another.
Since Python handles the implicit data type conversion, the programmer does not have to
convert the data type into another type explicitly.
The data type to which the conversion happens is called the destination data type, and the
data type from which the conversion happens is called the source data type.
x = 20
y = 25.5
Z=x+y
Here value in z, int type is converted to float type
Type Casting n type casting, the programmer has to change the data type as per their
requirement manually. In this, the programmer explicitly converts the data type using
predefined functions like int(), float(), str(), etc. There is a chance of data loss in this case
if a particular data type is converted to another data type of a smaller size.
x = 25 float(x) It converts into float type

SECTION – E [ 2 X 4 = 8 Marks ]
34 Write Python code to find whether the given item is present in the given list using 4
for loop.

Answer:
flag = 0
L = eval(input(‘input a list on numbers’)
E = int(input(‘item to be searched’)
K =len(L)
for p in range(K):
if E ==L(p):
flag = 1
print(‘found and
index is ‘,p)
if flag==0:
print(‘not found’)

35 Differentiate between break and continue statement used in python with examples. 4

Answer :
The break statement terminates the current loop , i.e the loop in which it appears, and
resumes execution at the next statement immediately after the end of that loop.if break
statement is inside a nested loop(loop inside another loop), break will terminate the
innermost loop.
When a continue statement is encountered, the control jumps to the beginning of the
loop for next iteration, thus skipping the execution of statements inside the body of
loop for the current iteration. As usual, the loop condition is checked to see if the loop
should continue further or terminate. If the condition of the loop is entered again, else
the control is transferred to the statement immediately following the loop.

You might also like