Python Arithmetic Operators-HackerRank Solution

0

The provided code stub reads two integers from STDIN, a and b. Add code to print three lines where:

 


  • The first line contains the sum of the two numbers.
  • The second line contains the difference between the two numbers (first - second).
  • The third line contains the product of the two numbers.

Example

a = 3
b = 5

Print the following: 


   8
   -2
   15



Input Format

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

Print the three lines as explained above.

Sample Input 0
 


  3
 
2


Sample Output 0

 


  5
  1
  6



Explanation 0

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


Solution
 


 if __name__ == '__main__':
 a = int(input())
 b = int(input())
 print((a + b), (a - b), (a * b), sep='\n')



Python Arithmetic Operators

Operator Description Syntax
+ Addition: adds two operands x + y
- Subtraction: subtracts two operands x – y
* Multiplication: Multiply two operands Mendel x*y
/ Division (float): divides the first operand by the second x / y
// Division (floor): divides the first operand by the second x // y
% Modulus: returns the remainder when first operand is divided by the second x % y
** Power : Returns first raised to power second x ** y

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !