TensorLearn
Back to Course
Python Essentials: The Engineering Approach
Module 3 of 20

3. Variables & Types

Integers (Arbitrary Precision)

In many languages (Java/C++), an integer has a max size (e.g., 2^64). In Python, integers can be infinite (limited only by RAM).

python
x = 2 ** 1000 print(x) # Prints a massive number. Python handles the memory allocation for you.

Floats (IEEE 754)

Floats are approximations. Computers use base-2 (binary), but humans use base-10. Some numbers cannot be represented perfectly.

python
print(0.1 + 0.2) # Output: 0.30000000000000004

Engineering Tip: Never compare floats with ==. Use a small "epsilon" difference or math.isclose().

Strings (Unicode)

Python strings are immutable sequences of Unicode characters.

  • 'A' is a character.
  • "Hello" is a string.
  • """Multi-line""" is for documentation.

F-Strings

The fast and clean way to format.

python
name = "Alice" print(f"Name: {name.upper()}") # Expressions work inside {}

Mark as Completed

TensorLearn - AI Engineering for Professionals