The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Python's floor, ceil, fabs, and trunc Functions

TODO: Pull subtitle into page object
Code
import math

nums = [23, 37.1, 48.9, -7, -12.3, -26.9]

print("original  floor   ceil   fabs  trunc")

for num in nums:
    floored = math.floor(num)
    ceiled = math.ceil(num)
    fabsed = math.fabs(num)
    trunced = math.trunc(num)
    print(str(num).rjust(8, ' '), end=" ")
    print(str(floored).rjust(6, ' '), end=" ")
    print(str(ceiled).rjust(6, ' '), end=" ")
    print(str(fabsed).rjust(6, ' '), end=" ")
    print(str(trunced).rjust(6, ' '), end=" ")
    print()
Results
original  floor   ceil   fabs  trunc
      23     23     23   23.0     23 
    37.1     37     38   37.1     37 
    48.9     48     49   48.9     48 
      -7     -7     -7    7.0     -7 
   -12.3    -13    -12   12.3    -12 
   -26.9    -27    -26   26.9    -26 

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Python's floor, ceil, fabs, and trunc Functions

This is a scratchpad post look at the 
different python math functions

-- code
-- python

import math

nums = [23, 37.1, 48.9, -7, -12.3, -26.9]

print("original  floor   ceil   fabs  trunc")

for num in nums:
    floored = math.floor(num)
    ceiled = math.ceil(num)
    fabsed = math.fabs(num)
    trunced = math.trunc(num)
    print(str(num).rjust(8, ' '), end=" ")
    print(str(floored).rjust(6, ' '), end=" ")
    print(str(ceiled).rjust(6, ' '), end=" ")
    print(str(fabsed).rjust(6, ' '), end=" ")
    print(str(trunced).rjust(6, ' '), end=" ")
    print()

-- results/

original  floor   ceil   fabs  trunc
      23     23     23   23.0     23 
    37.1     37     38   37.1     37 
    48.9     48     49   48.9     48 
      -7     -7     -7    7.0     -7 
   -12.3    -13    -12   12.3    -12 
   -26.9    -27    -26   26.9    -26 

-- /results

-- ref
-- title: Python: Mathematical Functions
-- url: https://docs.python.org/3/library/math.html

-- categories
-- Python 

-- metadata
-- date: 2023-10-23 16:39:55
-- id: 2xbduadg
-- site: aws
-- type: scratch 
-- status: published