Question 20 of 22intermediate🔧 ApplyShort Answer3 marks

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

(i)

num1 = int('3.14') print(num1)

Answer

ValueError (cannot convert string '3.14' directly to int)

(a)

num1 += num2 + num3 print (num1)

Answer

9

(b)

num1 = num1 ** (num2 + num3) print (num1)

Answer

1024

(c)

num1 **= num2 + num3

Answer

1024 (no print statement, so no output displayed)

(d)

num1 = '5' + '5' print(num1)

Answer

55

(e)

print(4.00/(2.0+2.0))

Answer

1.0

(f)

num1 = 2+9*((3*12)-8)/10 print(num1)

Answer

27.2

(g)

num1 = 24 // 4 // 2 print(num1)

Answer

3

(h)

num1 = float(10) print(num1)

Answer

10.0

(j)

print('Bye' == 'BYE')

Answer

False

(k)

print(10 != 9 and 20 >= 20)

Answer

True

(l)

print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)

Answer

True

(m)

print(5 % 10 + 10 < 50 and 29 <= 29)

Answer

True

(n)

print((0 < 6) or (not(10 == 6) and (10<0)))

Answer

True

Explanation

This question tests operators in Python including arithmetic, assignment, relational, and logical operators. The context explains that ** performs exponentiation, // performs floor division, and string concatenation uses + operator. For (a), num1 += num2 + num3 means num1 = 4 + (3+2) = 9. For (b) and (c), 4**5 = 1024. For (d), '5'+'5' concatenates strings. For (e), 4.00/4.0 = 1.0. For (f), following operator precedence: 2+9*((312)-8)/10 = 2+928/10 = 2+25.2 = 27.2. For (g), 24//4//2 = 6//2 = 3. For (h), float(10) converts to 10.0. For (i), int('3.14') raises error as int() cannot parse decimal strings directly. For (j), string comparison is case-sensitive. For (k)-(n), logical expressions evaluate using operator precedence and truth values.