Ask Question
24 June, 08:29

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.

+1
Answers (1)
  1. 24 June, 11:43
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers