Informatics Practices
Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = 2 + 9 * ((3*12)-8)/10
print(num1)
Python Control Flow
3 Likes
Answer
27.2
Working
num1 = 2 + 9 * ((3*12)-8)/10
Let's calculate this step by step, following the precedence of operators in Python:
1. Evaluate the innermost parentheses first:
3 * 12 = 36
2. Replace and continue evaluating inside the parentheses:
((3*12)-8) => (36 - 8) = 28
3. Now, evaluate the multiplication and division:
9 * 28 = 252
4. Continue with dividing by 10:
252 / 10 = 25.2
5. Finally, add 2:
2 + 25.2 = 27.2
The print(num1) statement outputs 27.2
Answered By
1 Like
Related Questions
Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = '5' + '5' print (num1)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
print(4.00 / (2.0+2.0))Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = float(10) print(num1)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.
num1 = int('3.14') print(num1)