Python math Module
PCAP objective 1.2 is perform evaluations using the math module, and it is one of the most answerable objectives in either exam - the functions do what their names say. Two things are worth care: there are four different ways to turn a float into an integer and they disagree on negative numbers, and every trigonometric function takes radians, so sin(90) is not 1.
Modules and Packages Guide 5 of 25 Intermediate
- OSUbuntu 26.04 LTS
- Python3.14.4
- pip25.1.1
- TimeAbout 15 min
math.isclose arrived in Python 3.5 and math.cbrt in 3.11. Everything the syllabus names has been present since Python 3.0 and behaves identically.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
This guide includes
Use this for the math objective. This matters because there are four ways to drop the fractional part and they disagree on negative numbers - which is exactly what the questions are built from.
- using the five constants
- meeting four ways to lose a fraction, and where they disagree
- using powers, roots and logarithms
- working in radians, which every trigonometric function does
- comparing floats with
isclose, and meeting the three ways math refuses
Before you start
-
The constants
-
Four ways to lose a fraction, and they disagree
-
Powers, roots and logarithms
-
Trigonometry works in radians
-
Comparing floats, and testing for the odd values
-
How math refuses
-
What the exam does with this objective