Informatics Practices
Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 += num2 + num3
print(num1)
Python Control Flow
3 Likes
Answer
9
Working
In the above code, num1 += num2 + num3 is a shorthand notation for num1 = num1 + num2 + num3.
Given,
num1 = 4
num2 = 3
num3 = 2
First, the expression num2 + num3 is evaluated:
num2 + num3 = 3 + 2 = 5
Now the expression becomes:
num1 = num1 + 5
which translates to:
num1 = 4 + 5 = 9
Answered By
2 Likes
Related Questions
Construct a logical expression to represent each of the following conditions:
(a) Marks are greater than or equal to 70 but less than 100.
(b) Num is between 0 and 5 but not equal to 2.
(c) Answer is either 'N' OR 'n'.
(d) Age is greater than or equal to 18 and gender is male.
(e) City is either 'Kolkata' or 'Mumbai'.
Find error in the following code (if any) and correct it by rewriting the code and underline the corrections:
code=input ("Enter season code : ") if code=w: print "winter season" elif code==r: PRINT "rainy season" else: Print "summer season"Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = num1 ** (num2 + num3) print (num1)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 **= num2 + c print (num1)