Computer Science, asked by smriti75, 1 year ago

Write a python program that will return true if the two given integers value are equal or their Sum difference is 5?​


Georges2467: hi smriti
Georges2467: i am shivaay
Georges2467: from Delhi

Answers

Answered by w0lf
3

a = input("enter a")

b = input("enter b")

def result(a, b)

if (a + b >= 5)

return true

else

return false

print(" %d ") % result(a, b)

im no python expert but may be this will work.

Answered by HanitaHImesh
0

Question

Write a python program that will return true if the two given integers value are equal or their Sum or their difference is 5?​

  • To write a code in Python, for the given conditions, we first have to take two integers as an input from the user.
  • Then, we have to define a function with two parameters, which will be the numbers taken as an input.
  • We will use 'or' keyword to match the given conditions.
  • Also, to make modulus of the values, take the built-in abs() function.
  • Finally, print the output to the console and also call the function, without which the function will not get executed.

Code:

#taking input from the user

a = int(input("enter a"))

b = int(input("enter b"))

#defining a function

def result(a, b):

   if(a == b or abs(a-b) == 5 or abs(a+b) == 5):

       return True

   else:

       return False

#printing the result

print(result(a, b))

#SPJ3

Similar questions