0% found this document useful (0 votes)
1 views7 pages

Class-8 Python Worksheet

The document is a Python worksheet containing multiple-choice questions related to Python programming concepts such as case sensitivity, identifiers, operators, and expressions. It includes questions about the output of specific code snippets, the order of precedence, and valid variable names. Each question is followed by options and explanations for clarity.

Uploaded by

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

Class-8 Python Worksheet

The document is a Python worksheet containing multiple-choice questions related to Python programming concepts such as case sensitivity, identifiers, operators, and expressions. It includes questions about the output of specific code snippets, the order of precedence, and valid variable names. Each question is followed by options and explanations for clarity.

Uploaded by

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

Python Worksheet

1. Is Python case sensitive when dealing with identifiers?


a) yes
b) no
c) machine dependent
d) none of the mentioned

2. What is the maximum possible length of an identifier?


a) 31 characters
b) 63 characters
c) 79 characters
d) none of the mentioned
Explanation: Identifiers can be of any length.

3. What will be the output for the given program.


a = 4.5
b=2
print (a//b)
a) 2.0
b) 3.0
c) 2.45
d) 3.45
Explanation: This type of division is called truncating
division where the remainder is truncated or dropped.

4. Which of the following cannot be a variable?


a) __init__
b) in
c) it
d) on
(in is a keyword)
5. All keywords in Python are in _________
a) lower case
b) UPPER CASE
c) Capitalized
d) None of the mentioned
Explanation: True, False and None are capitalized while the
others are in lower case.

6. Which of the following is an invalid variable?


a) our_string_2
b) 2nd_string
c) too
d) _cl

7. Which is the correct operator for power(xy)?


a) X^y
b) X**y
c) X^^y
d) None of the mentioned

8. Which one of these is floor division?


a) /
b) //
c) %
d) None of the mentioned

9. What is the order of precedence in python?


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
Explanation: For order of precedence, just remember this
PEMDAS (similar to BODMAS).

10. What is the answer to this expression, 22 % 3 is?


a) 7
b) 1
c) 0
d) 5
Explanation: Modulus operator(%) gives the remainder.
So, 22%3 gives the remainder, that is, 1.

11. What is the output of this expression, 3*1**3?


a) 27
b) 9
c) 3
d) 1
Explanation: First this expression will solve 1**3 because
exponential has higher precedence than multiplication, so
1**3 = 1 and 3*1 = 3. Final answer is 3.

12. Which one of the following has the highest precedence


in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses
13. What is the average value of the following Python
code?
Grade1=90
Grade2=80
Average=(Grade1 + Grade2) / 2
print(Average)
a) 85.0
b) 85.1
c) 95.0
d) 95.1

14. Select an option that prints-


Hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

15. The following is displayed by a print function call.


Select all of the function calls that result in this output.
1. Keyboard
2. Monitor
3. Web camera
a)print(“’1.keyboard\n2.monitor\n3.Web camera’”)
b)print(“’1.keyboard2.monitor3.Web camera’”)
c)print(" 1.keyboard\n 2.monitor\n 3.Web camera")
d)print(’1.keyboard2.monito3.rWeb camera’)

16. Evaluate the expression given below


if A = 16 and B = 15.
A%B//A

a) 0.0
b) 0
c) 1.0
d) 1
17. Which of the following is the truncation division
operator?

a) /
b) %
c) //
d) |

18. What is the value of the following expression?


float(22//3 + 3/3)
a) 8
b) 8.0
c) 8.3
d) 8.33

19. What are the values of the following Python


expressions?
2**(3**2)
(2**3)**2
2**3**2

a) 64, 512, 64
b) 64, 64, 64
c) 512, 512, 512
d) 512, 64, 512

20. What will be the output of the following Python


expression?

print(4.00/(2.0 + 2.0))

a) Error
b) 1.0
c) 1.00
d) 1
21. 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

22. The expression 2**2**3 is evaluates as: (2**2)**3.

a) True
b) False

Explanation: The value of the expression (2**2)**3 =


4**3 = 64. When the expression 2**2**3 is evaluated in
python, we get the result as 256, because this expression
is evaluated as 2**(2**3). This is because the
associativity of exponentiation operator (**) is from right
to left and not from left to right.

23. What will be the output of the following Python code?

for I in range(15, 89,10)


print(i)

a)15, 25, 35, 45, 55, 65, 75, 85


b) 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
80, 85
c) Countings from 15 to 89
d) 15, 89, 10
24. What will be the output of the following Python code?

i=1
while i<8:
if i%2==0:
break
print(i)
i+=2

a)1, 3, 5, 7, 9, 11
b)1
c)1, 3, 5, 7
d)1, 2, 3, 4, 5, 6, 7, 8

25. Which can be an Identifier among them in Python?


a) 1abc
b) $12a
c) _xy1
d) @python

You might also like