Write A Python Program Using Function To Check Whether Two Numbers Are Equal Or Not

Hi Programmers, welcome to my blog, lets try to get python solution for write a python program using function to check whether two numbers are equal or not.







Title :

Python Problem : Write A Python Program Using Function To Check Whether Two Numbers Are Equal Or Not


Description :

Lets define a function taking two arguments, compare using if statement if they are equal, if yes pass true else pass false boolean value as return code to main function. In the main function ask user to enter two variables. Call the function to check and get the result, if result true print values are equal else not equal, nan


Code :

def compare(a, b):
    if a == b:
        return True
    return False

x = int(input("Enter First Number : "))
y = int(input("Enter Second Number : "))

result = compare(x, y)
if result == True:
    print("Two numbers are equal")
else:
    print("Two numbers are not equal")


Conclusion :

Once you are done with reading the above code, open your python editor, try to write the program by yourself. This will improve your coding skills, try changing variable names, change operators and execute it.

Thank you for reading my article about write a python program using function to check whether two numbers are equal or not if you have any queries about above solution, please comment down below, if you like this article share it with your friends.

 

 


Gruha Lakshmi Update - How to Change Mobile Number in Ration Card Offline in Karnataka