Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #============================================================================================================
- #Useful Python math functions
- #-------------------------------------------------------------
- import math
- pi = 3.14
- print(round(pi)) #ROUNDS TO NEAREST WHOLE INTEGER
- #-------------------------------------------------------------
- import math
- pi = 3.14
- print(math.ceil(pi)) #ROUND A NUMBER UP TO NEAREST INTEGER
- #-------------------------------------------------------------
- import math
- pi = 3.14
- print(math.floor(pi)) #ROUND A NUMBER DOWN TO NEAREST INTEGER
- #-------------------------------------------------------------
- import math
- pi = -3.14
- print(abs(pi)) #GIVES THE ABSOLUTE VALUE OF A NUMBER
- #-------------------------------------------------------------
- import math
- pi = -3.14
- print(pow(pi,2)) #RAISE BASE NUMBER TO THE POWER OF 2
- #-------------------------------------------------------------
- import math
- pi = 3.14
- print(math.sqrt(420)) #SQUARE ROOT FUNCTION
- #-------------------------------------------------------------
- import math
- pi = 3.14
- X = 1
- Y = 2
- Z = 3
- print(max(X,Y,Z)) #FINDS THE LARGEST VALUE BETWEEN X, Y, & Z
- #-------------------------------------------------------------
- import math
- pi = 3.14
- X = 1
- Y = 2
- Z = 3
- print(min(X,Y,Z)) #FINDS THE LOWEST VALUE BETWEEN X, Y, & Z
- #-------------------------------------------------------------
- #============================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement