DEV Community

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

Posted on • Edited on

3 3

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series