Skip to main content

Advice For Beginners To Get Up and Running with Python

1. Why a Proper Setup Matters

Before diving into code, a structured setup helps you avoid “spaghetti” projects that become hard to maintain. Using a virtual environment ensures your dependencies are isolated (so you don’t clash with system Python or other projects). Having a clear skeleton (separating imports, variables, functions, and “main program logic”) gives you and future readers a map of where each piece lives. Many software engineering experts emphasize that good architecture up front can save you enormous friction later — clean structure is one of the foundations of maintainability. (Ciklum)






2. Creating a Virtual Environment  💾💻💹

Here’s a typical workflow:

  1. Open your terminal / command prompt in your project folder (or create a new folder).

  2. Run (for Python 3):

    python3 -m venv venv
    

    This creates a directory venv/ (or whatever you name it) containing the isolated Python environment.

  3. Activate it:

    • On macOS / Linux: source venv/bin/activate

    • On Windows (PowerShell): .\venv\Scripts\Activate.ps1

    • On Windows (cmd): .\venv\Scripts\activate.bat

  4. You’ll see your prompt change (often with (venv) prefix). Now pip install only affects that environment.

Once inside, you can install packages via pip install ... and freeze them with pip freeze > requirements.txt so others (or future you) can replicate the setup.


3. Creating the .py File & Project Skeleton  📶📝📡

With your environment ready, create a file, e.g. main.py (or any name matching your application). You might also create a folder structure like:

my_project/
  venv/
  requirements.txt
  main.py
  helpers.py
  data/
    rates.json
  tests/
    test_main.py

But even a single file is fine to begin. In your .py file, you can start with a template layout — something like:

# ========================
# Imports / libraries
import os
import sys
# (other imports)

# ========================
# Global variables / configuration
API_KEY = "…"  # or load from env
DATA_PATH = "data/rates.json"
SUPPORTED = ["USD", "EUR", "GBP"]

# ========================
# Functions / classes
def load_rates(path):
    ...

def convert(from_currency, to_currency, amount):
    ...

class SomeHelper:
    ...

# ========================
# Main program logic (entry point)
def main():
    from_cur = input("From: ")
    to_cur = input("To: ")
    amt = float(input("Amount: "))
    result = convert(from_cur, to_cur, amt)
    print(f"{amt} {from_cur} = {result} {to_cur}")

if __name__ == "__main__":
    main()

This layout separates concerns: imports at top, config/variables next, then functions or classes, then the “main” runner logic. It makes it easier to read, test, or expand later.




4. Detailing Each Section

Let me walk you through each “region” of that template:

  • Imports / libraries: All your import statements go here — standard library first, then third-party, then internal modules (if you split your code).

  • Global variables / configuration: Place constants or settings (file paths, supported currencies, API keys, etc.). Avoid scattering “magic numbers” inside functions.

  • Functions / classes: These are the “units of work” — each function or class should have a clear responsibility. Prefer small, testable pieces.

  • Main program logic: This is what the script does when invoked. Wrapping it in a main() function and guarding with if __name__ == "__main__": is Pythonic and helps you later if you want to import parts instead of always running.

This separation supports readability, easier testing, and gradual growth of your project.


5. Expert Advice & Best Practices to Begin

When starting a project, many experienced developers advise:

  • Start small, iterate: Don’t over-engineer everything at the start. Get a minimal “vertical slice” working, then refactor and expand.

  • Design for coupling & cohesion: Keep dependencies loose (low coupling) and group related behaviors (high cohesion) — a classic architectural principle. (Rheinwerk Computing Blog)

  • Prefer readability & simplicity: Over cleverness. Code is read more often than written. The simplest solution that works is often best. (Wikipedia)

  • Fix root causes when bugs appear: Rather than patching superficially, dig one layer deeper (as John Walley suggests) to prevent repeated issues. (walley.org.uk)

  • Document your decisions: Use lightweight architecture docs or “architecture decision records” so future you or collaborators know why things were done. (Medium)

These practices help your project remain maintainable as it grows.


6. Example Walkthrough: Currency Converter

Here’s how you might evolve your template into your converter:

  1. Imports

    import json
    import os
    
  2. Configuration

    RATES_FILE = "data/rates.json"
    
  3. Functions / classes

    def load_rates(path):
        with open(path) as f:
            return json.load(f)
    
    def convert(rates, from_cur, to_cur, amt):
        if from_cur != "EUR":
            amt = amt / rates[from_cur]
        return round(amt * rates[to_cur], 2)
    
  4. Main logic

    def main():
        rates = load_rates(RATES_FILE)
        fc = input("From: ").upper()
        tc = input("To: ").upper()
        amt = float(input("Amount: "))
        res = convert(rates, fc, tc, amt)
        print(f"{amt} {fc} = {res} {tc}")
    

Empowering yourself with a working baseline helps you experiment, refactor, and expand without getting lost.


7. Why This Approach Works from a Software Architecture Perspective

Experts often stress that clean architectural decisions early can prevent entropy (design decay) later. Over time, ad-hoc changes can lead to rigid, fragile, or tightly coupled code. (Rheinwerk Computing Blog) By laying down clear boundaries (imports, config, logic), you prevent code from “leaking” across layers.

Also, software architects often emphasize documenting why architecture was chosen, not just what it is — the rationale helps future changes stay coherent. (Medium) Starting small and refactoring incrementally is another recommended strategy in real projects (don’t overdesign prematurely). (Scott Logic)

Finally, by modularising your code early (e.g. separating converter logic from I/O), you prepare the code for scaling — e.g., if later you build a web frontend or API, you won’t have to rewrite everything.





8. Summary & Next Steps

In summary:

  • Use a virtual environment to isolate dependencies.

  • Start with a clear file skeleton (imports, config, functions, main logic).

  • Implement a minimal working version, then refactor and grow.

  • Follow expert advice: keep things simple, design for low coupling and high cohesion, document decisions, and address root causes of bugs.


My blog post is just a jumping off point for people new to programming, I want to demystify the the world of software engineering, programming, coding, AI and various other aspects of computing.

For more detailed tutorials and educational material that's going to be far better than my blog post I recommend this website:  Geeks For Geeks 

Comments

Popular Past Posts

Meet Cuthbert Baines: A Passionate and High-Achieving Professional Programmer

   Hello, and welcome to my corner of the internet! I'm Cuthbert Baines , a seasoned computer programmer with a passion for solving complex problems and building efficient, scalable software. With years of experience in the industry, I’ve honed my skills to not only deliver high-quality code but also to contribute meaningfully to projects that push the boundaries of technology. My Journey into Programming I’ve always had a deep curiosity about how things work, which led me to the world of computer science and programming. From my first lines of code to tackling challenging algorithms, the journey has been a rewarding one. Over time, my focus has expanded to include full-stack development , machine learning , and software architecture , but the heart of my work remains in solving real-world problems with clean, maintainable code. What Sets Me Apart? As a professional programmer, I pride myself on a few key principles that guide my work: Attention to Detail : Whether I’m...

A Beginner’s Guide to AI & Machine Learning Terms (No Tech Background Needed!)

📶💻💹 Artificial Intelligence (AI) and Machine Learning (ML) are terms that are used by a lot of people but do you know about the technical nuts and bolts of how they actually work? If you don't that's OK, — I’ve broken down some of the most common terms you might hear in the world of AI/ML into simple explanations anyone can understand. Plus, if you're using Google Colab , there's a built-in AI assistant called Gemini that can help you understand and write code but you need to know the right questions to ask it first.   1. NLP (Natural Language Processing) 🎤🎧 NLP is a branch of AI that helps computers understand and work with human language. Think of it as the technology behind things like chatbots, language translators, and voice assistants like Siri or Alexa. It allows machines to “read” and make sense of text or speech, just like we do. 2. BERT (Bidirectional Encoder Representations from Transformers) BERT is a special AI model developed by Google that ...

Reintroducing Cuthbert Baines For Anyone New In His Network

 Reintroducing Cuthbert Baines For New People In His Network As a recent IT graduate I'm new to the IT industry so I don't have the kinds of professional connections I need to be given a head-start, I'm one of the many new IT graduates applying for the relatively few  graduate jobs out there.  I am prioritising my personal and professional development right now.  I wish I had gone to University 20 years ago but for reasons outside my control I was written off at 16 so I missed out.  I don't give up easily up so I finally went to Hallam University when I was 35 and got a 2.1 in computing in 2025, now I'm willing to go the extra mile and do what needs to be done to make up for lost time!  I had to get a job when I was 18 so I've got the professionalism, life experience and wisdom of a (late) 30-something who's worked his entire adult life combined with the youthful intellectual energy of an explorer and a pioneer new to the IT sector with his own fresh innov...