Operations on numbers

Exercises

Imagine being in the XXth century.
You want to compute 34844 - 343788 / 4 + (284937 + 4389472) * 24.
However, it is quite bothersome to compute that by hand.
You decide to use a computer for that.
You first test the computer by writing the following code:

print(2+5)
print(4*2 + 1)
print(4*(2 + 1))

As expected, it returns 7, 9, and then 12.


Compute 34844 - 343788 / 4 + (284937 + 4389472) * 24 in Python.

Rules

On numbers, the following operations exist between numbers:

  • to add
  • to substract
  • to multiply / to divide


Just like in mathematics :

  • Mulitplication and division take priority
  • You can add parentheses to tell which operations should be first


These rules work with Python, C, C++, C#, Java, Javascript, PHP… and a lot more.