Getting Started with Python

3 min read

So, you’re ready to dive into Python? Whether you’re aiming to automate boring tasks, crunch data, build apps, or just understand the buzz around AI and ML — Python is the language you want on your side.

This guide will walk you through:

  1. Installing Python on any OS (Windows/Linux/macOS)
  2. Choosing a Python IDE
  3. Writing your first Python script
  4. Understanding comments and best practices
  5. Running Python files vs. using the interactive shell
  6. A real-world use case: Creating a simple “Hello World Logger”

🛠️ 1. Installing Python (Windows, Linux, macOS) #

🔹 Windows #

  1. Go to https://www.python.org/downloads
  2. Download the latest version for Windows.
  3. Important: During installation, check the box that says “Add Python to PATH.”
  4. Click “Install Now” and finish setup.

✅ To verify:

python --version

🔹 macOS #

  • macOS comes with Python 2.x, but you’ll want Python 3.x.
  • Use Homebrew:
brew install python

✅ Verify:

python3 --version

🔹 Linux (Ubuntu/Debian) #

sudo apt update
sudo apt install python3

✅ Verify:

python3 --version

🧠 2. Choosing a Python IDE #

You’ll need a place to write your code. Here are your top choices:

IDEBest ForPros
VS CodeGeneral Python devLightweight, extensions, IntelliSense
PyCharmPython-heavy devSmart code, auto-complete, debugger
Jupyter NotebookData scienceInline output, interactive cells

🔸 Recommended for Beginners: Start with VS Code or Jupyter Notebook.


🐣 3. Writing Your First Python Script #

Create a file called hello.py and write this:

print("Hello, world!")

Then run it using:

python hello.py

🎉 Congrats! You’ve just written and run your first Python program.


📝 4. Comments & Best Practices #

Comments help you and others understand what your code is doing.

# This is a single-line comment

"""
This is a
multi-line comment
"""

print("Python is cool!")  # This prints a message

✅ Best Practices: #

  • Use meaningful variable names.
  • Add comments to explain “why,” not “what.”
  • Keep lines short and readable.
  • Follow PEP 8 guidelines for code style.

⚙️ 5. Running Python Files vs. Interactive Shell #

🔸 Running a File (Script Mode) #

Great for writing full programs.

python hello.py

🔸 Interactive Shell (REPL) #

Perfect for testing quick ideas:

python
>>> print("Testing...")

🧠 You can also use IDLE, Python’s built-in GUI shell.


💼 6. Real-World Use Case: Hello World Logger #

Let’s say you’re logging messages every time your system starts a job or script. Here’s how you can build a very basic logger.

🧾 hello_logger.py #

from datetime import datetime

def log_message(message):
    # Format: [YYYY-MM-DD HH:MM:SS] Message
    now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    log_entry = f"[{now}] {message}\n"
    
    # Append log to a file
    with open("log.txt", "a") as f:
        f.write(log_entry)

# Run the logger
log_message("Hello, world!")
print("Logged: Hello, world!")

🔍 How It Works: #

  • Uses Python’s built-in datetime module
  • Appends a log line to log.txt every time it runs
  • Real-world use? Logging job runs, user events, or system messages

✅ Summary #

TopicKey Takeaway
Installing PythonUse official installer or package manager
IDEsVS Code or Jupyter are great starts
First ScriptSimple print("Hello, world!")
CommentsMake your code readable
Running CodeUse both script and interactive modes
Real-World Use CaseLogging messages in real time

🧪 What’s Next? #

In the next tutorial, we’ll go deep into Variables, Data Types, Input/Output, and Operators — the foundation of writing logic in Python.

Want me to start with that next? Just say “Next part please” and I’ll drop the full tutorial.

Let’s keep building 🚀

Updated on June 9, 2025