Arithmetic Operators in Python - Hacker Rank Solution


Arithmetic Operators in Python - Hacker Rank Solution



Problem


Tutorial :
Let's learn about Python's arithmetic operators.
First, let's read two integers:
#Python 2
a = int(raw_input())
b = int(raw_input())

#Python 3
a = int(input())
b = int(input())

The three basic arithmetic operators are the following:
Addition (+)
Subtraction (-)
Multiplication (*)
(We'll learn about division in the next task.)

Task :
Read two integers from STDIN and print three lines where:
  1. The first line contains the sum of the two numbers.
  2. The second line contains the difference of the two numbers (first - second).
  3. The third line contains the product of the two numbers.



Input Format :

The first line contains the first integer, a. The second line contains the second integer, b.

Constraints :

  • 1 <= a <= 10^10
  • 1 <= b <= 10^10

Output Format :

Print the three lines as explained above.



Sample Input :

3
2

Sample Output :

5
1
6

Explanation :

3 + 2 = 5
3 - 2 = 1
3 * 2 = 6



Solution :


1
2
3
4
5
6
7
8
9
# Arithmetic Operators in Python - Hacker Rank Solution
if __name__ == '__main__':
    a = int(raw_input())
    b = int(raw_input())
    # Arithmetic Operators in Python - Hacker Rank Solution START
    print(a+b);
    print(a-b);
    print(a*b);
    # Arithmetic Operators in Python - Hacker Rank Solution END





Disclaimer :-
the above hole problem statement is given by hackerrank.com but the solution is generated by the codeworld19 authority if any of the query regarding this post or website fill the following contact form thank you.

Next Post Previous Post
No Comment
Add Comment
comment url