Arithmetic Operators In Python Hackerrank Solution
Published October 31, 2023 by Jarvis Silva
Looking for the Hackerrank arithmetic operators solution in Python? You are at the right place. In this article, I will share the Python arithmetic operators Hackerrank solution.
Hackerrank is a popular online platform which has many programming challenges and competitions which allows developers to participate into them and improve their programming skill.
Arithmetic Operators Hackerrank Question
The provided code stub reads two integers from STDIN, and . Add code to print three lines where:
- The first line contains the sum of the two numbers.
- The second line contains the difference of the two numbers (first – second).
- The third line contains the product of the two numbers.
You can find the full question of this problem here: Hackerrank arithmetic operators question.
This is a very easy problem, it asks you to take two integer inputs from the user then we just need to use arithmetic operators and in the first line print the sum of both numbers, second print the difference and lastly product of them.
Before moving to the solution you should definately try to do this on your own it is very easy but still if you can’t solve it don’t worry you can check the below solution and understand this program.
Arithmetic Operators Hackerrank Solution In Python
# Read two integers from STDIN
num1 = int(input())
num2 = int(input())
# Calculate the sum, difference, and product
sum_result = num1 + num2
difference_result = num1 - num2
product_result = num1 * num2
# Print the results
print(sum_result)
print(difference_result)
print(product_result)
Above is the python solution for arithmetic operators Hackerrank question, you can submit the above code in hackerrank and it should show you congratulations you solved this challenge.
This was for this article, I hope you found what you were looking and if you want more hackerrank solutions then visit here: Hackerrank python solutions.
Thank you for reading, Happy coding 😊