#!/usr/bin/env python3
###################################################################################
# Python numeric functions
###################################################################################
print("Content-Type: text/html \n")     #http header with newline char (required for the web)
import math                             #import the math module

num  =  1234567.89                      #a floating point number
str1 = "1234567.89"                     #a string

print('<pre>')                          #to produce better display on the web 

print(F"num  = {num}  \t", type(num) )
print(F"str1 = {str1} \t", type(str1))

print ('is num a number.......', not math.isnan(num))          #is the number "not a number"?
print ('round up .............', math.ceil(num))
print ('round down............', math.floor(num))
print ('round to 1 decimal....', round(num,1))

num2 = int(num)                                             #convert the float to a int
print ('convert to integer...:', num2)

num3 = float(num2)                                          #convert the int to a float
print ('convert to float.....:', num3)

num4 = float(str1)                                          #convert the string to a float
print ('convert string to num:', num4, type(num4))

str2 = str(num)                                             #convert the number to a string
print ('convert num to string:', str2, type(str2))

print ('multiply by 3........:', num*3)
print ('take to the power 3..:', num**3)
print ('take to the power 3..:', pow(num,3))
print ('take the mininum.....:', min(num, 100, 99999999) )      #minimum of enclosed args
print ('take the maximum.....:', max(num, 100, 99999999) )      #maximum of enclosed args
print ('sum the list.........:', sum([num, 100, 99999999]) )    #must be a list

print(F"format a number......: {num4:,.4f} ")                   #commas and 4 decimal places