DEV Community

Cover image for How To Make A Simple Number Comparer In Python
Abhishek Hari
Abhishek Hari

Posted on • Updated on

How To Make A Simple Number Comparer In Python

In this article I will show you how to make a extremely simple number comparer!

This program will compare two numbers and tell which one is greater.

This is a great project to improve your skills! As they say, practice makes perfect.

Making Inputs

First, we need to make the inputs so that the user can input their desired values.

First Number

num1 = int(input("❯ Enter A Number: "))
Enter fullscreen mode Exit fullscreen mode

Second Number

num2 = int(input("❯ Enter Another Number: "))
Enter fullscreen mode Exit fullscreen mode

Writing Logic

Lastly, we need to write if and else statement to and use the comparing operators <, >, = to check which number is greater.

if num1 > num2:
    print("" + str(num1) + " is greater than " + str(num2))

else:
    print("" + str(num2) + " is greater than " + str(num1))
Enter fullscreen mode Exit fullscreen mode

That's it, congratulations! You have made a number comparer!
Here is a picture of the finished product:
Final Product

Top comments (0)