#!/usr/bin/env python3; ############################################################################### # This program demonstrates the math integer functions. # # Copyright © 2020 Richard Lesh. All rights reserved. ############################################################################### import Utils import math import random # Begin Main a = 5 b = 10 c = -2 # abs, floor, ceil, round, trunc, min, max print("abs({0:d}) = {1:d}".format(a, abs(a))) print("abs({0:d}) = {1:d}".format(c, abs(c))) print("min({0:d}, {1:d}) = {2:d}".format(a, b, min(a, b))) print("max({0:d}, {1:d}) = {2:d}".format(a, b, max(a, b))) print("min({0:d}, {1:d}) = {2:d}".format(b, c, min(b, c))) print("max({0:d}, {1:d}) = {2:d}".format(b, c, max(b, c))) # random numbers print("random({0:d}) = {1:d}".format(a, int(a * random.random()))) print("random({0:d}) = {1:d}".format(a, int(a * random.random()))) print("random({0:d}) = {1:d}".format(a, int(a * random.random()))) print("random({0:d}) = {1:d}".format(a, int(a * random.random()))) print("random({0:d}) = {1:d}".format(a, int(a * random.random()))) print("random({0:d}) = {1:d}".format(b, int(b * random.random()))) print("random({0:d}) = {1:d}".format(b, int(b * random.random()))) print("random({0:d}) = {1:d}".format(b, int(b * random.random()))) print("random({0:d}) = {1:d}".format(b, int(b * random.random()))) print("random({0:d}) = {1:d}".format(b, int(b * random.random()))) print("random(2) = {0:d}".format(int(2 * random.random()))) print("random(2) = {0:d}".format(int(2 * random.random()))) print("random(2) = {0:d}".format(int(2 * random.random()))) print("random(2) = {0:d}".format(int(2 * random.random()))) print("random(2) = {0:d}".format(int(2 * random.random()))) print("random() = {0:f}".format(random.random())) print("random() = {0:f}".format(random.random())) print("random() = {0:f}".format(random.random())) print("random() = {0:f}".format(random.random())) print("random() = {0:f}".format(random.random()))