Ask Question
21 December, 10:14

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. 21 December, 11:53
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers