Python TutorialLesson 28Free preview
Python Math
This lesson is part of Python · All levels
Summary
Math modules contain ready-made mathematical functions such as square roots, up and down dials, to pi constants. We just import the module and then call the function through the point, without having to calculate the formula from zero. For financial numbers that demand precision, Python provides decimal modules as an alternative to float.
Key points
- Math.sqrt() calculates the square root and math.pow() performs the ranking.
- Math.ceil() round up while math.floor() round down.
- Math.pi and math.e are very accurate in-built constants.
- For precision decimal numbers, decimal modules are more recommended than floats.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.