math module
The standard library module of mathematical functions and constants, such as sqrt, floor, ceil, sin and pi.
In more detail
Its functions work on floats and integers; math.isclose compares floats safely. For averages and medians use the statistics module.
Example
import math
math.sqrt(16), math.floor(2.7)Related terms
- square root — The number that multiplied by itself gives a given number, found in Python with math.sqrt(x) or x ** 0.5.
- pi — The ratio of a circle's circumference to its diameter, about 3.14159, available in Python as math.pi.
- statistics module — The standard library module for basic statistics such as mean, median, mode and standard deviation.
Taught in
- What Python Is, And Where It Came From — Hands-on Python: Complete Video Course & Book
- Exponents, Roots And Float Formats — Hands-on Python: Complete Video Course & Book
- Modules And The Import System — Hands-on Python: Complete Video Course & Book
- A Standard Library Tour — Hands-on Python: Complete Video Course & Book
- The Class That Shared One List — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Import Variants, dir() And sys.path — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- math, random And platform — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Handlers, args, raise And assert — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Twelve Traps, Mostly Objects — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Mock, Review And Exam Day — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep