Skip to content
Exercises · Q7

Q.Give the output of the following when num1 = 4, num2 = 3, num3 = 2

a)
num1 += num2 + num3
print (num1)
b)
num1 = num1 ** (num2 + num3)
print (num1)
c)
num1 **= num2 + num3
d)
num1 = '5' + '5'
print(num1)
e)
print(4.00/(2.0+2.0))
f)
num1 = 2+9*((3*12)-8)/10
print(num1)
g)
num1 = 24 // 4 // 2
print(num1)
h)
num1 = float(10)
print (num1)
i)
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)))
Yanam BieapTextbookSubjective· 3mImportance★★★★★est
69% · 34/49 Questions
🔒 Locked · start free trial →

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.

PartWorking (step by step)Output
anum1 += num2 + num3 → num1 = 4 + (3 + 2) = 4 + 59
bnum1 = num1 ** (num2 + num3) → 4 ** 51024
cnum1 **= 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 + concatenates55
e4.00 / (2.0 + 2.0) = 4.0 / 4.01.0
f2 + 9*((3*12) - 8)/10 → 312 = 36; 36 − 8 = 28; 928 = 252; 252/10 = 25.2; 2 + 25.227.2
g24 // 4 // 2 — floor division is left-associative → (24//4)//2 = 6//23
hfloat(10) converts int to float10.0
iint('3.14') — int() accepts only an integer-looking stringValueError (see below)
j'Bye' == 'BYE' — string comparison is case-sensitiveFalse
k10 != 9 → True; 20 >= 20 → True; True and TrueTrue
lLeft 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 TrueTrue
m5 % 10 = 5; 5 + 10 = 15; 15 < 50 → True; 29 <= 29 → True; True and TrueTrue
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.