First, the code stubs read two integers from STDIN:
#Python 2 a = int(raw_input()) b = int(raw_input()) #Python 3 a = int(input()) b = int(input())
In the above statements,
input() are the Python 2 and Python 3 methods to read lines from STDIN. The methods return a string by default. Since this problem uses numeric data, the input value must be converted to an integer. Convert a string to an integer using
Now, a bit about Arithmetic Operators
The three basic arithmetic operators are the following:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
There are several division methods that will be discussed in the next challenge. Of the three operators shown, multiplication takes precedence over addition and subtraction. Addition and subtraction have equal precedence.
- Given , the parentheses are unnecessary due to precedence. Multiplication is performed before addition. This equation can be written more simply as .
- To multiply by , write .