haleywisman41 haleywisman41
  • 08-07-2020
  • Computers and Technology
contestada

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.

Respuesta :

stanfordgoddy stanfordgoddy
  • 08-07-2020

Explanation:

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

Answer Link

Otras preguntas

what document were Montesquieu ideas used in?
Adult tickets to a basketball game cost $5 and student tickets are $1. A total of $2,874 was collected when selling 1,246 tickets. How many of each type of tick
what was daily life for children who grew up on farms during colonial times?
how can I prove using laws of exponent that 16^2 and 2^8 are equal to each other?????????
An object that is undergoing constant circular motion ,is it accelerating?
What is Electromagnetic role in the atom
-4(4x+4)=2(2-7x) how do u do this and you have to use WHO and check your answer by plugging it in the original equation.SHOW ALL WORK
What are equivalent fractions for one fourth
At 2:00p.m., joon and gerace start driving toward each other from points 174 miles apart. They meet at 4:00 p.m. joon's speed was 7 miles per hour greater than
How do you solve -x +y=-5 -3x+4y=-12
good job