Chapter 10: Numbers and Mathematics
Complete Python lesson for very beginners. Technical words are explained in simple language, and every outline topic includes a practical example, expected output, steps, and practice.
Chapter Overview
This Python tutorial chapter covers Numbers and Mathematics through 15 connected topics. Work through the examples in order, check the expected output, and complete the practice after each topic.
- 10.1 Integers
- 10.2 Floating-Point Arithmetic
- 10.3 Complex Numbers
- 10.4 Rounding
- 10.5 Absolute Values
- Plus 10 additional Python topics in this chapter.
10.1 Integers
Integers is part of Numbers and Mathematics. In simple language, it means a whole number such as 5 or -2.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import math
print(math.sqrt(81))Expected Output
9.0Step-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
10.2 Floating-Point Arithmetic
Floating-Point Arithmetic is part of Numbers and Mathematics. In simple language, it means a number that can contain a decimal part.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
a = 10
b = 3
print(a + b, a - b, a * b, a / b)Expected Output
13 7 30 3.3333333333333335Step-by-Step Explanation
- Create two numbers.
- Apply arithmetic operators.
- Notice that / produces a floating-point result.
10.3 Complex Numbers
Complex Numbers is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import math
print(math.sqrt(81))Expected Output
9.0Step-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
10.4 Rounding
Rounding is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
value = 3.14159
print(round(value, 2))Expected Output
3.14Step-by-Step Explanation
- Pass the number to round().
- The second argument requests two decimal places.
- The rounded value is returned.
10.5 Absolute Values
Absolute Values is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
print(abs(-12))Expected Output
12Step-by-Step Explanation
- abs() returns distance from zero.
- A negative input becomes positive magnitude.
- The result is numeric.
10.6 Powers
Powers is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
print(2 ** 5)
print(pow(3, 2))Expected Output
32
9Step-by-Step Explanation
- ** raises a number to a power.
- pow() can express the same kind of operation.
- Both examples return integers.
10.7 Minimum and Maximum
Minimum and Maximum is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
values = [8, 2, 11, 5]
print(min(values))
print(max(values))Expected Output
2
11Step-by-Step Explanation
- min() finds the smallest item.
- max() finds the largest item.
- They work on compatible comparable values.
10.8 sum()
sum() is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
values = [2, 4, 6]
print(sum(values))Expected Output
12Step-by-Step Explanation
- Create numeric values.
- sum() adds the items.
- The total is returned.
10.9 Math Module
Math Module is part of Numbers and Mathematics. In simple language, it means a Python file that can provide reusable code.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import math
print(math.sqrt(81))Expected Output
9.0Step-by-Step Explanation
- import makes a module available.
- Use module.name to access its contents.
- The standard-library math module provides sqrt().
10.10 Constants
Constants is part of Numbers and Mathematics. In simple language, it means a value you intend not to change.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import math
print(math.sqrt(81))Expected Output
9.0Step-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
10.11 Trigonometry
Trigonometry is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
try:
number = int("not-a-number")
except ValueError as error:
print(type(error).__name__)Expected Output
ValueErrorStep-by-Step Explanation
- Put risky conversion inside try.
- Catch the specific ValueError you expect.
- Handle the problem without hiding unrelated errors.
10.12 Logarithms
Logarithms is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import math
print(math.sqrt(81))Expected Output
9.0Step-by-Step Explanation
- Read the example from top to bottom.
- Identify the value, object, or operation related to this topic.
- Change one small input and predict the result before running it.
10.13 Random Numbers
Random Numbers is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
import random
rng = random.Random(7)
print(rng.randint(1, 6))Expected Output
3Step-by-Step Explanation
- Create a local random-number generator with a fixed seed for a repeatable lesson.
- randint(1, 6) chooses an integer in that inclusive range.
- Do not use ordinary random tools for passwords or security secrets.
10.14 Decimal Arithmetic
Decimal Arithmetic is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
a = 10
b = 3
print(a + b, a - b, a * b, a / b)Expected Output
13 7 30 3.3333333333333335Step-by-Step Explanation
- Create two numbers.
- Apply arithmetic operators.
- Notice that / produces a floating-point result.
10.15 Fractions
Fractions is part of Numbers and Mathematics. In simple language, it means a Python idea used while learning numbers and mathematics.
It is one building block of numbers and mathematics and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.
Python / Practical Example
from fractions import Fraction
print(Fraction(1, 3) + Fraction(1, 6))Expected Output
1/2Step-by-Step Explanation
- Create exact rational numbers.
- Add the fractions.
- Python simplifies the result.
Common Beginner Mistakes
- Copying code without predicting what each line does.
- Ignoring the first useful error message or traceback location.
- Mixing tabs/spaces or changing indentation accidentally.
- Using data of the wrong type for an operation.
- Trying to learn many advanced variations before mastering one small working example.
Chapter Practice
- Choose three topics from this chapter and re-type their examples without copying and pasting.
- For each example, change one input and predict the output first.
- Explain five technical terms from this chapter in your own beginner-friendly words.
- Create one small program that combines at least two chapter topics.
- Keep notes about errors you made and what fixed them.
Mini Project / Challenge
Create a small Python exercise that combines at least three ideas from Numbers and Mathematics. Start with a tiny working version, test it, then improve it one step at a time.
- Choose three topics from this chapter.
- Write or adapt a small Python example using those topics.
- Predict the output before running the code.
- Test at least one different input.
- Write two sentences explaining what the program does and what you learned.
20 Questions & Answers
1. What is the main goal of Chapter 10?
The goal is to understand numbers and mathematics through small explanations, examples, and practice.
2. Should I memorize every command or method?
No. Understand the pattern, practice the common form, and learn how to read documentation when you need exact details.
3. Why are the examples small?
Small examples isolate one idea at a time, which makes errors easier to understand and fix.
4. What should I do when an example gives an error?
Read the last part of the traceback, check spelling and indentation, confirm the required package or file exists, and compare the input types with what the operation expects.
5. Why should I predict output before running code?
Prediction forces you to reason about the program instead of only copying it.
6. What should I remember about Integers?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
7. What should I remember about Floating-Point Arithmetic?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
8. What should I remember about Complex Numbers?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
9. What should I remember about Rounding?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
10. What should I remember about Absolute Values?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
11. What should I remember about Powers?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
12. What should I remember about Minimum and Maximum?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
13. What should I remember about sum()?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
14. What should I remember about Math Module?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
15. What should I remember about Constants?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
16. What should I remember about Trigonometry?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
17. What should I remember about Logarithms?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
18. What should I remember about Random Numbers?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
19. What should I remember about Decimal Arithmetic?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.
20. What should I remember about Fractions?
Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.