Python Math Module - Fabs Function

Method Name:

fabs(aNumber_in)

Method Overview: 


Returns the absolute value of a Number.
If we draw a number line the absolute value of a number tells the magnitude of its distance from zero,
without considering the direction. Hence both the numbers -6 and 6 will be at a distance of 6 from zero.

import math

# Absolute zero temperature is -273 degree celcius

AbsolouteZero = -273

Magnitude = math.fabs(-273)

print("Printing only the magnitude for absolute zero: {}".format(Magnitude))

# Number of storeys below ground floor in my apartment...0 being ground floor

maxFloorBelow = -2

FloorCountBelowGround = math.fabs(maxFloorBelow)

print("The number of floors below ground: {}".format(FloorCountBelowGround))

Output

Printing only the magnitude for absolute zero: 273.0

The number of floors below ground: 2.0


Copyright 2022 © pythontic.com