Exercises · Q7
Q.Give the output of the following when num1 = 4, num2 = 3, num3 = 2
a)
num1 += num2 + num3
print (num1)
num1 += num2 + num3
print (num1)
b)
num1 = num1 ** (num2 + num3)
print (num1)
num1 = num1 ** (num2 + num3)
print (num1)
c)
num1 **= num2 + num3
num1 **= num2 + num3
d)
num1 = '5' + '5'
print(num1)
num1 = '5' + '5'
print(num1)
e)
print(4.00/(2.0+2.0))
print(4.00/(2.0+2.0))
f)
num1 = 2+9*((3*12)-8)/10
print(num1)
num1 = 2+9*((3*12)-8)/10
print(num1)
g)
num1 = 24 // 4 // 2
print(num1)
num1 = 24 // 4 // 2
print(num1)
h)
num1 = float(10)
print (num1)
num1 = float(10)
print (num1)
i)
num1 = int('3.14')
print (num1)
num1 = int('3.14')
print (num1)
j)
print('Bye' == 'BYE')
k)
print(10 != 9 and 20 >= 20)
l)
print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)
m)
print(5 % 10 + 10 < 50 and 29 <= 29)
n)
print((0 < 6) or (not(10 == 6) and (10<0)))
print('Bye' == 'BYE')
k)
print(10 != 9 and 20 >= 20)
l)
print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)
m)
print(5 % 10 + 10 < 50 and 29 <= 29)
n)
print((0 < 6) or (not(10 == 6) and (10<0)))
Yanam CbseNCERTSubjective· 3mImportance★★★★★est
69% · 34/49 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Fourteen independent snippets evaluated with num1 = 4, num2 = 3, num3 = 2 — a tour of Python's operator precedence, type conversion and boolean logic; one snippet (i) raises a ValueError.
The idea being tested is how Python evaluates expressions: operator precedence (** binds tighter than *//, which bind tighter than +/-), the difference between numeric addition and string concatenation, true division / versus floor division //, and how comparison results feed and/or. Each part is independent, so every part starts again from num1 = 4, num2 = 3, num3 = 2.
| Part | Working (step by step) | Output |
|---|---|---|
| a | num1 += num2 + num3 → num1 = 4 + (3 + 2) = 4 + 5 | 9 |
| b | num1 = num1 ** (num2 + num3) → 4 ** 5 | 1024 |
| c | num1 **= num2 + num3 → num1 = 4 ** 5 = 1024, but the snippet has no print() | (nothing displayed; num1 holds 1024) |
| d | '5' + '5' — both operands are strings, so + concatenates | 55 |
| e | 4.00 / (2.0 + 2.0) = 4.0 / 4.0 | 1.0 |
| f | 2 + 9*((3*12) - 8)/10 → 312 = 36; 36 − 8 = 28; 928 = 252; 252/10 = 25.2; 2 + 25.2 | 27.2 |
| g | 24 // 4 // 2 — floor division is left-associative → (24//4)//2 = 6//2 | 3 |
| h | float(10) converts int to float | 10.0 |
| i | int('3.14') — int() accepts only an integer-looking string | ValueError (see below) |
| j | 'Bye' == 'BYE' — string comparison is case-sensitive | False |
| k | 10 != 9 → True; 20 >= 20 → True; True and True | True |
| l | Left side: 2**2 = 4; 6*4 = 24; 10 + 24 = 34. Right side: 9//4 = 2; 2 − 3 = −1. So 34 != -1 → True. Then 29 >= 29/9 → 29 >= 3.222… → True. True and True | True |
| m | 5 % 10 = 5; 5 + 10 = 15; 15 < 50 → True; 29 <= 29 → True; True and True | True |
| n | (0 < 6) → True; or short-circuits — the whole expression is already True (the right side, not(10==6) and (10<0) → True and False → False, is never needed) | True |
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.