0% found this document useful (0 votes)
55 views6 pages

Python Class 11 Test Gen 002

The document contains a series of programming questions and answers related to Python, covering topics such as comments, output of code snippets, loop execution counts, variable names, keywords, immutable data types, and syntax corrections. Each question is followed by multiple-choice options and the correct answer is provided. The document serves as a quiz or examination material for assessing knowledge of Python programming.

Uploaded by

tutor nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views6 pages

Python Class 11 Test Gen 002

The document contains a series of programming questions and answers related to Python, covering topics such as comments, output of code snippets, loop execution counts, variable names, keywords, immutable data types, and syntax corrections. Each question is followed by multiple-choice options and the correct answer is provided. The document serves as a quiz or examination material for assessing knowledge of Python programming.

Uploaded by

tutor nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Roll No : Time -

Date : MM : 22

1. Single line comment entry can be given by:


(a) //
(b) $ 1
(c) #
(d) “
Answer:
(c)

2. Write the output of:


x=5;
y = 10;
x += 2*y;
print(“x=”,x, “and y=”,y) 1
(a) x=10 and y= 25
(b) x=25 and y= 25
(c) x=25 and y= 10
(d) x=15 and y= 10
Answer:
(c)

3. Find the output generated by the following code: 1


(a) x=2
y=3
x+=y
print(x,y)
(b) x=8
y=2
x+=y
y-=x
print(x,y)
(c) a=5
b=10
a+=a+b
b*=a+b
print(a,b)
(d) p=10
q=20
p*=q//3
q+=p+q**2
print(p,q)
(e) p=5/2
q=p*4
r=p+q
p+=p+q+r
r+=p+q+r
q-=p+q*r
print(p,q,r)
(f) p=2/5
q=p*4
r=p*q
p+=p+q-r
r*=p-q+r
q+=p+q
print(p,q,r)
Answer:
(a) 5 3
(b) 10 –8
(c) 20 300
(d) 60 480
(e) 27.5 –642.5 62.5
(f) 1.7599999999999998 4.96 0.512

4. How many times the given loops will be excecuted:

Answer:
(i) 9 times
(ii) 2 times
(iii) 3 times
(iv) 2 times
5. Find the output of the following code:

Answer:
(i) 8 5
(ii) 0 2
(iii) 20 30
(iv) 66.67 126.67
(v) 4 –10 7
(vi) 8 8 0

6. What will be the output for the following Python statements? [CBSE 2021]
D=("AMIT" : 90, "RESHMA":96, "SUKHBIR":92, "JOHN":95)
print("JOHN" in D, 90 in D, sep = "#")
(a) True#False 1
(b) True#True
(c) False#True
(d) False#False
Answer:
(a)

7. Identify the output of the following Python statements: [CBSE 2021]


D={}
T=("ZEESHAN", "NISHANT", "GURMEET", "LISA")
for i in range (1, 5):
D[i]=T[i–1]
1
print(D)
(a) {"ZEESHAN", "NISHANT", "GURMEET", "LISA"}
(b) "ZEESHAN", "NISHANT", "GURMEET", "LISA"
(c) {[1,"ZEESHAN"], [2, "NISHANT"], [3,"GURMEET"], [4,"LISA"]}
(d) {1,"ZEESHAN", 2, "NISHANT", 3,"GURMEET", 4,"LISA"}
Answer:
(d)

8. Which of the following is not a valid variable name in Python. Justify reason for
it not being a valid name: [CBSE 2021 (C)]
(a) 5Radius
1
(b) Radius_
(c) _Radius
(d) Radius
Answer:
(a)

9. Which of the following are keywords in Python: [CBSE 2021 (C)]


(a) break
(b) check 1
(c) range
(d) while
Answer:
(a), (c), (d)

10. Write the names of the immutable data objects from the following: [CBSE
2021 (C)]
(a) List
(b) Tuple 1
(c) String
(d) Dictionary

Answer:
(b), (c)

11. Consider the given expression :


57 or not 7>4
Which of the following will be the correct output, if the given expression· is
evalutated? [CBSE 2023]
1
(a) True
(b) False
(c) NONE
(d) NULL
Answer:
(a)

12. Which of the following operators will return either True or false? [CBSE 2023] 1
(i) +=
(ii) !=
(iii) =
(iv) *=
Answer:
(ii) !=

13. Rewrite the following code in python after removing all syntax error(s).
Underline each correction done in the code.
input(‘Enter a word’,W)
if W = ‘Hello’ 1
print(‘Ok’)
else:
print(‘Not Ok’)
Answer:
W=input(‘Enter a word’) / /Error 1
if W == ‘Hello’ : / /Error 2,Error 3
print(‘Ok’)
else : / /Error 4
print(‘Not Ok’)

14. What possible outputs(s) are expected to be displayed on screen at the time
of execution of the program from the following code? Also specify the
maximum values that can be assigned to each of the variables BEGIN and
3
LAST.

Answer:
(ii)

15. Based on the following python code, find out the expected correct output(s) 3
from the options (i) to (iv)
import random
lst=["Red","Blue","Green","Yellow"]
for i in range(5,2,-1):
print(lst[random.randint(1,2)],end="%")
(i) Blue%Green%Green%
(ii) Blue%Red%Green%
(iii) Blue%Green%Yellow%
(iv) Blue%Blue%Red%
Answer:
(i)

16. Based on the following python code, find out the expected correct output(s)
from the options (i) to (iv)
tup=("Red","Blue","Green","Yellow")
for i in range(3):
print(tup[random.randrange(1,4,2)],end="#") 3
(i) Blue#Blue#Yellow#
(ii) Red#Green#Green#
(iii) Blue#Yellow#Green#
(iv) Blue#Green#Yellow#
Answer:
(i)

You might also like