📝 Worksheet← Lesson
BitWithBite
Computational Mathematics · Quick Reference

Python for Mathematics Cheat Sheet

Computational Mathematics · Lesson 1/6
In one line: python is one of the most popular languages for doing math with code — its clean syntax and huge ecosystem of libraries make it a natural bridge between mathematical ideas and working software.

Key Ideas

1Basic Arithmetic in Python. Python supports +, -, *, / directly, plus ** for exponents and % for remainder (modulo).
2Variables and the math Module. Python's built-in math module provides functions like math.sqrt(), math.sin(), math.log(), and constants like math.pi.
3Lists for Sequences. Python lists (like [1,2,3,4]) are a natural way to store and work with sequences of numbers, such as a dataset or a sequence's terms.
4Loops for Repeated Calculations. A for loop lets you repeat a calculation for every item in a list or range, such as computing every term of a sequence.
5Functions for Reusable Formulas. Defining a function with def lets you reuse a formula (like a quadratic formula solver) any time you need it, without rewriting the math each time.

Worked Examples

What does the Python expression 3 + 4 * 2 evaluate to (following order of operations)?
11
What does 2**10 evaluate to in Python?
1024
Write a Python function that returns the square of a number.
def square(x): return x * x

Formulas

Exponent: 2**3 evaluates to 8
Modulo (remainder): 17 % 5 evaluates to 2
math.sqrt(16) evaluates to 4.0

Practice Yourself

What does 10 % 3 evaluate to in Python?
1
What does 5**2 evaluate to?
25
What Python module provides math.sqrt and math.pi?
The math module