mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Added examples to the README file
This commit is contained in:
18
README.md
18
README.md
@@ -3,7 +3,23 @@ This is a collection of classes and functions that I have found I use often enou
|
||||
|
||||
#Algorithms
|
||||
This is a collection of functions that is not large enough to justify a class, but too helpful to not keep track of.
|
||||
|
||||
Usage Examples:
|
||||
primes = getPrimes(number) #This returns all prime numbers less than or equal to number
|
||||
primes = getNumPrimes(number) #This returns a list of the first number prime numbers
|
||||
factors = getFactors(number) #This returns a list of all the factors of number
|
||||
divisors = getDivisors(number) #This returns a list of all the divisors of number
|
||||
fib = getFib(number) #This returns the fibonacci number F[number]
|
||||
fib = getAllFib(number) #This returns a list of all of the fibonacci numbers less than or equal to number
|
||||
num = prod(numbers) #This returns the value of the product of all the elements in the list numbers
|
||||
|
||||
#Stopwatch
|
||||
This class is used for timing portions of your code.
|
||||
You can use the various get functions to return a specific resolution of time or you can use the getString function to return the time at the "best" resolution in the target format of xxx.xxx {resolution}
|
||||
Usage Example:
|
||||
timer = Stopwatch()
|
||||
timer.start()
|
||||
#The code to be timed here
|
||||
timer.stop()
|
||||
print("It took " + timer.getString() + " to run this algorithm")
|
||||
#It could also be done this way
|
||||
print("It took " + timer.getMilliseconds() + " to run this algorithm")
|
||||
|
||||
Reference in New Issue
Block a user