Write the output of the following:-
a,b=10,12
a=a*2
b=b+5
print(a,b)
Answers
Answered by
4
a, b = 10, 12
a = a * 2
b = b + 5
print(a, b)
The output for the program is:
20 17
- Here, two variable named a and b are declared.
- Variable a stores value 10 and the other stores value - 12.
- In the second line, the value of variable a is double. '*' operator is used to perform multiplication. a * 2 = 20 and now a = a * 2 or a = 20.
- In the third line, 5 is added to the variable b. '+' operator is used for addition and for concatenating two or more strings. b = b + 5 or b = 12 + 5 or b = 17. So, b becomes 17.
- In the fourth line, the values of a and b are displayed on the screen.
See attachment for verification.
Attachments:
Similar questions