XII-CS (Ch. 1) ASSIGNMENT-1

You might also like

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

DELHI PUBLIC SCHOOL, BAREILLY

XII- Computer Science


ASSIGNMENT-1
(CHAPTER 1 PYTHON REVISION TOUR- I)
Q.1 Evaluate the Following Expressions:
a) 12 + 3 * ( 4 – 6 )/2
b) (2 + 3) ** 3 – 6 / 2
c) 12 * 3 % 5 + 2 * 6 // 4
d) 10 != 9 and 20 >= 20
e) 10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9
f) (0 < 6) or (not(10 == 6) and (10<0))
g) 5 % 10 + 10 < 50 and 29 <= 29
h) 5 < (5>3 and 10<20)
i) 3**2-81//9%2 + (3+4)
j) not 12 > 6 and 7 < 17 or not 12 < 4
Q.2 Fill in the blanks:
a) _____________operator is used for indentation.
b) The ___________ statement prematurely ends the execution of the current
while/for loop.
c) ___________ error occurs during program execution due to incorrect or illegal
values used in some operations.
d) A_______ is the smallest element of a Python script that is meaningful to the
interpreter.
e) A named memory location which is used to store data is known as____________.
f) ________ is used for the multiple line comments.
g) _______ operator, concatenates multiple copies of the same string.
h) The default separator character of print() is _________
Q.3 MCQ:
1. Identify the valid arithmetic operator in Python from the following:
a) ? b) < c) ** d) and
2. Floor division can be done using :
a) % b) // c) / d) **
3. Relational Operator is:
a) and b) ! c) < d) ===
4. Identify the invalid logical operator in Python from the following:
a) and b) or c) not d) nor
5. The continue statement is used:
a) To pass the control to the next iterative statement
b) To come out from the iteration
c) To break the execution and passes the control to else statement
d) To terminate the loop
6. Write the type of tokens of the following:
(i) if (ii) roll_no
7. Which of the following is/are Keywords in Python ?
a) break b) check c) range d) while
8. Which of the following is an invalid Identifier(s) ?
a) my_day_2 b) 2nd_day c) day_two d) _2
9. What will be the value of the expression: 14+13%15
a) 14 b) 27 c) 12 d) 0
10.What will be the value of the expression: 22%3.0
a) 7 b) 1 c) 1.0 d) 7.0
11.What will be the value of the expression: 3**1**3
a) 27 b) 3 c) 1 d) 9
12.Which of the following is an invalid Identifier ?
a) my_day_2 b) 2nd_day c) day_two d) _2
13.Out of the following, find the identifiers, which cannot be used for naming
Variable or Functions in a Python program:
_Cost, Price*Qty, float, switch, Address one, Delete, Number12, do
14.Which of the following can be considered as valid identifiers?
a) Hello-world2 b) _helloworld2 c) 2_hello world d) hello_world@1
15.Identify the statement from the following which will raise an error:
a) print(“1”*3) b) print(1*3) c) print(“1”+3) d) print(“1”+“3”)

Q.4 Rewrite the following code in Python after removing all syntax error(s).
Underline each correction done in the code.
Runs = ( 10, 5, 0, 2, 4, 3 )
for I in Runs:
if I=0:
print (Maiden Over)
else
print(Not Maiden)
Q.5 Find the output of the following code:
Num = 20
Sum = 0
for i in range (10, Num, 3):
Sum+=i
if i%2==0:
print (i*2)
else:
print (i*3)
Q.6 Find the output of the following program:
x=10
y=0
while x>y:
print( x,y)
x=x-1
y=y-1
Q.7 Rewrite the following while loop into for loop:
i=88
while(i>=8):
print (i)
i- = 8
Q.8 Rewrite the following code in Python after removing all syntax error(s). Underline
each correction done in the code.
30=Value
for VAL in range(0,Value)
IF val%4==0:
print (VAL*4)
Elseif val%5==0:
print (VAL+3)
else
print(VAL+10)
Q.9 Write the output from the following code:
n = 50
i = 5
s = 0
while i<n:
s+ = i
i+ = 10
print (“i=”,i )
print (“sum=”,s)
Q.10 Write the output from the following code:
a = 110
while a > 100:
print(a)
a -= 2
Q.11 Write the output from the following code:
i = 0; sum = 0
while i < 9:
if i % 4 == 0:
sum = sum + i
i = i + 2
print (sum)

Q.12 Write the output from the following code:


for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y)
Q.13 Write the output from the following code:
var = 7
while var > 0:
print ('Current variable value: ', var)
var = var -1
if var == 3:
break
else:
if var == 6:
var = var -1
continue
print ("Good bye!")

You might also like