Bombing Run Help

@X95 @isnode

Code Library definition

a library is a collection of precompiled routines that a program can use. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.

So in the case of Math we have a structure like an object that has properties (attributes) and functions (methods).

We could have created this ourselves if it didn’t exist.

For instance

class MathLibrary:
    PI = 3.14195
    
    def __init__():
        return True
    
    def factorial(self, number):
        factorialNumber = 1
        while number > 0:
            factorialNumber = factorialNumber * number
            number -= 1
        return factorialNumber
        
    def power(self, number, power):
        powerNumber = 1
        while power > 0:
            powerNumber = powerNumber * number
            power -= 1
        return powerNumber

Math2 = MathLibrary()

hero.say(Math2.PI)
hero.say(Math2.factorial(4) )
hero.say(Math2.power(-1,3) )
        
1 Like