Ask Question

Write a python function absDiff ( ...) that takes two integers as parameters, gets the absolute value of both, subtracts the second from the first, and returns the difference.

+4
Answers (1)
  1. 14 April, 15:59
    0
    Remember, an absolute value is the non-negative value of a number in this case the integer.

    First, using the abs () function. Here's an example:

    # Some random integers

    variableA = - 308

    variableB = 301

    Second, # Get the absolute values of those integers

    absA = abs (variableA)

    absB = abs (variableB)

    Next,

    # Output the results

    print ("Absolute values of integers with 'abs () ':")

    print ("|", variableA, "| = ", absA, sep="")

    Finally,

    Use abs (variableA-variableB):

    In [1]: abs (-308-301)

    Out[1]: 307
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a python function absDiff ( ...) that takes two integers as parameters, gets the absolute value of both, subtracts the second from ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers