Question Bank Subject: Computer Science: Class: XII Sub. Code: 083
Question Bank Subject: Computer Science: Class: XII Sub. Code: 083
Question Bank Subject: Computer Science: Class: XII Sub. Code: 083
CHAPTERS
Python Revision Tour
5. If the following code is executed, what will be the output of the following code?
name=”ComputerSciencewithPython”
print(name[3:10])
a) mputerS b) puterSc c) mputerScie d) puterScien
6. m = 16
m = m+1
if m<15:
print(m)
else:
print(m+15)
a) 32 b) 16 c) 17 d) 31
7. Write the value that will be stored in variable t after the execution of the
following code. How many times will the loop execute?
sum = score = 0
while score <=3:
score = score +1
sum = sum + score
t = sum // 3
print(t)
1
a) Value of t will be 4 Loop executes 3 times
b) Value of t will be 3 Loop executes 4 times
c) Value of t will be 3 Loop executes 3 times
d) Value of t will be 4 Loop executes 4 times
11. Write the value that will be assigned to variable x after executing the following
statement:
x = 3 + 36/12 + 2*5
a)4 b)25 c)16 d)16.0
a) 2 b) 2.0 c) 20 d) 3
3
24. Give the output
for i in range(1,5):
print(i * i,end=’ ‘)
a) 1 2 3 4 5 b) 1 4 9 16 c) 1 9 4 16 d) 5 4 3 2 1
25. Write the value that will be stored in variable sum after execution of following
code?
sum=0
for i in range(9,5,-1):
if(i%3==0):
sum = sum + i
else:
sum = sum - i
print(i,sum)
a) 0 9 b) 6 0 c) 0 6 d) 9 0
27. What is the correct python code to display the last four characters of
string=“Digital India”
a) string[-4:] b) string [4:] c) string [*str] d) string [/4:]
29. The operator used to check if both the operands reference the same object
memory, is the .......... operator.
a) in b) is c) id d) ==
random.randint(3.5,7)
a) Error
b) Any integer between 3.5 and 7, including 7
c) Any integer between 3.5 and 7, excluding 7
d) The integer closest to the mean of 3.5 and 7
4
NOTE: Refer the topic random module and the following functions
associated with it.
1) random.random()
2) random.randint()
3) random.randrange()
random()
Returns a random floating point number between 0 and 1:
random.random()
# Output: 0.66486093215306317
randint()
random.randint(x, y)
random.randint(1, 8)
# Output: 8
randrange()