Answer to Question #165541 in Python for Prathyusha

Question #165541

Write a program to print the absolute difference between the two given numbers. (Absolute difference is the difference without the negative sign)


1
Expert's answer
2021-02-22T07:09:53-0500
#function to return the Absolute difference
def absDiff(a,b):
    return abs(a)-abs(b)

#test runs    
print(absDiff(-1,3)) #-2
print(absDiff(-1,-3)) #-2
print(absDiff(1,3)) #-2
print(absDiff(-5,3)) #2

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
29.04.21, 13:06

Dear v Viswanath post a new task

v Viswanath
29.04.21, 08:52

this program will be better a=int(input()) b=int(input()) c= a-b d=abs(c) print(d)

Assignment Expert
24.03.21, 12:20

Dear Alok please post a new question

Alok S
24.03.21, 12:11

if the given N1 is 200 and N2 is 500 The difference in number is 200 - 500 = -300 The absolute difference is 300. Sample Input 200 500 Sample Output 300 Sample Input -12 -1 Sample Output 11 How this will come

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS