Python Numbers
1. What are Numbers in Python?
Numbers are used to:
-
Count things
-
Do calculations
-
Solve math problems
Python supports different kinds of numbers.
2. Types of Numbers in Python
Python mainly has three types of numbers:
-
Integer (
int) -
Float (
float) -
Complex (
complex)
Beginners mostly use int and float.
3. Integer Numbers (int)
An integer is a whole number.
It has no decimal point.
Examples
4. Float Numbers (float)
A float is a number with a decimal point.
Examples
5. Complex Numbers (complex) (Basic Idea)
Complex numbers have:
-
a real part
-
an imaginary part
Example
π Beginners usually donβt use this now.
6. Basic Math Operations with Numbers
Python can do all common math.
Addition
Subtraction
Multiplication
Division
7. Other Useful Number Operations
Power (Exponent)
Modulus (Remainder)
Floor Division
8. Checking Number Type
Use type() to see number type.
Example
9. Converting Between Number Types
Integer to Float
Float to Integer
π Decimal part is removed.
10. Taking Number Input from User
Input is always text, so convert it.
Example
11. Common Beginner Mistakes
β Forgetting Conversion
β Correct:
β Dividing Integers Expecting Integer
Output:
Python always returns float for /.
12. Simple Practice Examples
Example 1: Simple Calculator
Example 2: Area of Rectangle
Example 3: Check Even or Odd
13. Summary (Python Numbers)
β Python supports different numbers
β int = whole number
β float = decimal number
β / gives decimal result
β Convert input before math
π Perfect for Beginner eBook
This chapter is ideal for:
-
Python beginner books
-
School & college students
-
Self-learners
If you want next, I can write:
-
Python Strings (easy)
-
Python Booleans
-
Operators
-
Number Exercises
-
MCQs with answers
Just tell me π
