Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Lesson 04

Simple and Readable Python

Why Python is simple: modules, garbage collection, and readable syntax.

Beginner10 min

What you will learn

By the end of this lesson, you'll understand:

  • Why is Python called a simple language?
  • What are the three factors behind its simplicity?
  • What do modules and garbage collection do?
  • How does readable syntax make programming easier?

Why is Python called simple?

Python was designed with one major goal:

Code should be written for humans first, and computers second.

Instead of forcing programmers to write complex syntax, Python reduces repetitive and low-level work.

Complex syntax vs clean Python

This readability benefits both beginners and large engineering teams.

Three Factors Behind Python's Simplicity

Factor 1 · Rich Set of Modules

A module is a collection of:

  • Functions
  • Variables (data members)
  • Classes

Instead of writing everything from scratch, Python lets you reuse built-in modules.

Common built-in modules

Module Purpose
math Mathematical operations
os Operating system functions
random Random numbers
calendar Calendar operations

Example

python
import math

num = 25
print(math.sqrt(num))

Output:

text
5.0

Visual explanation

math module provides sqrt and returns a result

Key idea: Modules save development time and reduce bugs.

Factor 2 · Automatic Memory Management

When a program creates data, memory is allocated automatically.

When that data is no longer needed, Python's Garbage Collector frees the unused memory.

How it works

Create object, garbage collector, free memory

Why is this important?

In languages like C, programmers manually allocate and release memory.

Python handles this automatically, allowing you to focus on solving business problems rather than memory management.

Note: The garbage collector works in the background—you don't usually call it yourself in everyday programming.

Factor 3 · User-Friendly Syntax

Python syntax is close to English.

You usually don't need:

  • Type declarations
  • Semicolons
  • Curly braces for blocks

Example

python
name = "Ravi"
age = 20

print(name, "is", age, "years old")

Output:

text
Ravi is 20 years old

Readability comparison

Traditional typed syntax vs Python

Python removes unnecessary syntax while keeping programs easy to understand.

Why Readability Matters in Teams

Imagine you're working with 50 developers on one project.

Which code is easier to maintain?

Hard to read Python style
More syntax Clean structure
More boilerplate Less code
Slower reviews Faster collaboration

Readable code is easier to:

  • Debug
  • Review
  • Maintain
  • Extend

This is one reason Python is widely used in enterprise software.

Real Example · Circle Area

Use the math module to calculate the area of a circle.

Formula

$$\text{Area} = \pi r^{2}$$

Python Program

python
import math

radius = 5
area = math.pi * radius * radius

print("Area of circle =", area)

Output:

text
Area of circle = 78.53981633974483

Step-by-step calculation

Radius, pi, multiply, result

Key Points

  • Modules provide reusable building blocks like math and os.
  • Garbage collection automatically removes unused memory.
  • Readable syntax reduces unnecessary typing and improves collaboration.
  • Python emphasizes human readability over complex language rules.

Practice Exercise

Write a program that calculates the area of a circle.

Expected Program

python
import math

radius = float(input("Enter radius: "))

area = math.pi * radius * radius

print("Area of circle =", area)

Sample Output

text
Enter radius: 5
Area of circle = 78.53981633974483

Challenge: Change the radius to 10 and verify the new area.

Interview Questions

  1. Why is Python called a simple language?
  2. What is a module? Give two examples.
  3. What is the purpose of Python's garbage collector?
  4. Why does Python not require type declarations in simple programs?
  5. Name the three factors that make Python simple.

Summary

Factor Benefit
Rich Modules Reuse existing code
Garbage Collection Automatic memory management
User-Friendly Syntax Easy to read and write

Python's simplicity is not about having fewer features—it's about reducing repetitive work so developers can focus on solving real problems.

Next

Next lesson: High-Level Programming Language — how Python hides low-level machine details and lets programmers think in human-friendly terms instead of hardware instructions.