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

Which events associated with the development of nuclear weapons occurred FIRST? A The Soviet Union developed an atomic bomb. B The United States developed an at
MAM I NEED HELP WHAT DO I NEED TO PUT!!!!!
The perimeter of a rectangular lawn is 108 meters it is 35 meters long how wide is it
PLS HELP NO LINKS CLICK TO SEE
Half a number decreased by two
help.Write an equation that represents the relationship between the x-value and the y-value.
8. Which of the following have bacteria in their root nodules that fix nitrogen? 1. Legumes b. Meat c. "Trees d. Algae
need help badly!!!!!
Escríbele una carta a tu “pen pal” donde le dices a tu amigo (a) que tus padres son muy estrictos y quieren que sigas las reglas de la casa. Dile lo que quieren
Explain why so many states seceded.