Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Python backend developer skills

        Learn Python backend developer skills for APIs, SQL, testing, security, and deployment with a runnable duplicate-request exercise and portfolio checks.

        A person practicing on a laptop in a quiet workspace

        The core Python backend developer skills are Python fundamentals, HTTP and API design, SQL and database transactions, automated testing, application security, Git, and deployment basics. Learn those skills through one small service before adding asynchronous programming, caching, or distributed systems.

        The core backend skills

        A Python backend developer builds and operates server-side software that receives requests, applies business rules, and reads or changes stored data. An application programming interface, or API, is the contract another program uses to communicate with that software.

        For a support-ticket service, daily work might mean clarifying a submission rule, changing Python logic and database behavior, writing tests, reviewing changes, and releasing the service. After release, you'd investigate errors and unexpected results. Backend work focuses on those behaviors rather than browser layouts.

        Skills behind a reliable request

        A reliable request combines readable Python, a clear communication contract, and database rules that protect stored data. A useful learning project makes all three visible.

        • Python: use functions to separate business rules from request handling, dictionaries and lists to represent data, and exceptions to handle errors. Learn modules for organizing code, type hints for documenting expected values, and dependency management for recording required packages.
        • HTTP: understand the protocol used for web requests and responses. Learn methods that express an operation, status codes that describe its outcome, and JSON, a text format for exchanging structured data.
        • SQL: learn to read and change relational data, join related tables, and use indexes to support lookups. Practice schema changes, which alter database structure, rather than recreating every database when requirements change.
        • Persistence: use a database transaction to commit related changes together or roll them back. Use a unique constraint, a database rule against repeated key values, when duplicates would violate a business rule.

        If functions and exceptions still feel unfamiliar, start with the Python course before adding web requests.

        Django and Flask are Python web frameworks. Choose one for your first small service; learning several at once makes it harder to separate HTTP concepts from framework conventions.

        Idempotency means arranging an operation so that repeating the same request doesn't repeat its business effect. For ticket creation, a retry should return the original ticket rather than create another ticket. A request key identifies the operation, while a database uniqueness rule prevents duplicate storage.

        A duplicate-request exercise

        Build a Python function that represents ticket-creation logic, not a running HTTP server. Use Python 3.12 or later with SQLite 3.24 or later; the database is temporary and starts empty whenever the script runs.

        Practice what this post teaches

        Save the following script as backend_demo.py and run the command in its instructions. The calls first repeat both original arguments, then change only the subject while keeping the request key unchanged. The final query verifies the stored rows after those calls.

        # Fictional exercise: support-ticket creation.
        # Target: repeating a request must create only one ticket.
        # Start: an empty, in-memory database.
        # Inputs are strings; blank subjects return status 400.
        # Same key and subject: return the stored subject with status 200.
        # Same key, different subject: return 409 without changing storage.
        # New key: create a ticket and return status 201.
        # Save as backend_demo.py and run: python backend_demo.py
        import sqlite3
        
        con = sqlite3.connect(":memory:")
        con.execute(
            "CREATE TABLE tickets ("
            "request_key TEXT PRIMARY KEY NOT NULL, subject TEXT NOT NULL)"
        )
        
        def create_ticket(request_key, subject):
            if not subject.strip():
                return 400, "Subject required"
            with con:
                inserted = con.execute(
                    "INSERT INTO tickets VALUES (?, ?) "
                    "ON CONFLICT(request_key) DO NOTHING",
                    (request_key, subject),
                ).rowcount
                stored = con.execute(
                    "SELECT subject FROM tickets WHERE request_key = ?",
                    (request_key,),
                ).fetchone()[0]
                if stored != subject:
                    return 409, "Request key already used"
                return (201 if inserted else 200), stored
        
        # First submission: create the ticket.
        print(create_ticket("req-101", "Printer offline"))
        # Repeat both original arguments.
        print(create_ticket("req-101", "Printer offline"))
        # Change only the subject argument; keep the original request key.
        print(create_ticket("req-101", "Scanner offline"))
        # Change the key to req-102 and the subject to spaces.
        print(create_ticket("req-102", "   "))
        # Verify the stored rows after all four calls.
        print(con.execute("SELECT request_key, subject FROM tickets").fetchall())
        con.close()
        
        # Expected output:
        # (201, 'Printer offline')
        # (200, 'Printer offline')
        # (409, 'Request key already used')
        # (400, 'Subject required')
        # [('req-101', 'Printer offline')]

        The primary key prevents repeated request keys. The question-mark placeholders bind values separately from SQL syntax, a technique called parameterized SQL. The stored-subject comparison detects reuse of a key for different content.

        In this exercise, 201 means created, 200 means a successful replay, 409 means a conflict, and 400 means invalid input. The function returns these numbers as data; an HTTP handler would need to turn them into actual response status codes.

        Tests and security checks

        Backend tests must check both the response and the stored state. Automate the exercise cases using a fresh database for each independent test, so one test doesn't depend on another test's changes.

        • First submission: expect 201 and exactly one stored row.
        • Identical replay: expect 200 and the original row, without an additional row.
        • Changed subject under the same key: expect 409 and the unchanged original subject.
        • Blank subject with a new key: expect 400 and no row for that new key.

        When you're ready to turn those checks into automated tests, use Pytest assertions and failure outcomes. An assertion checks whether an actual result matches an expected condition.

        Authentication establishes identity; authorization decides what that identity may do. In a real service, scope request keys to the authenticated customer and check access before returning stored ticket content. Don't trust a customer identifier merely because the request body includes one. Keep credentials outside source code and exclude secrets from diagnostic records.

        The exercise doesn't implement HTTP handling, user access, durable storage, external notifications, or concurrent-request testing. A database transaction alone doesn't guarantee that an external notification will be sent only once. That boundary is an important design problem, not something the replay response solves.

        Release and operating skills

        Backend ownership continues after the code works locally: you need repeatable releases and enough diagnostic information to investigate problems. Use Git to record focused changes, and make each change small enough for someone else to review.

        Keep environment-specific configuration outside source code. Review database migrations, which are controlled changes to database structure, alongside the application change. Document release and rollback steps, including whether an older application version can still use the changed schema.

        Logs record events, metrics measure behavior over time, and traces record a request's path through services. For the ticket project, explain how a diagnostic record would distinguish invalid input from a database error without recording credentials or private ticket content.

        Add asynchronous programming when coordinating waits for input and output becomes a concrete need; it doesn't automatically make CPU-heavy Python work faster. Background jobs, caching, and containers should follow a tested service rather than replace one. Show a reproducible setup, a passing test run, and one release risk before expanding the architecture.

        Learning order and portfolio proof

        Learn Python functions and exceptions first, then HTTP with one framework, SQL and transactions, tests and access checks, and finally deployment and diagnostics. Revisit the same ticket service at each stage so each new skill solves a recognizable problem.

        Skills mapped to inspectable evidence
        SkillEveryday taskPortfolio artifactVerification
        PythonValidate ticket inputFocused creation functionBlank input returns 400
        HTTPDefine response behaviorRequest and response contractReplay and conflict have distinct outcomes
        SQLPrevent duplicate storageSchema and parameterized queriesReplay leaves one row
        TestingProtect existing behaviorAutomated response and state testsEach test runs independently
        SecurityRestrict ticket accessCustomer-scoping design and access testsAnother customer can't retrieve the ticket
        GitMake reviewable changesFocused commit historyEach change has a clear purpose
        OperationsRelease and diagnose changesSetup, release, and diagnostic notesA reader can reproduce the setup

        Package the runnable script, a README with setup and expected output, automated tests, and the database schema. Add a short explanation of why changed content under an existing key returns a conflict. Label proposed security and HTTP work as proposed until you've implemented and tested those parts.

        For continued practice, use the Python for software engineers course. The Work Gym checks exercises automatically with hints that name mistakes, and learners can share a portfolio.

        In an interview, explain the business rule first: retries mustn't create duplicate tickets. Then identify the database invariant, a condition that must remain true: request keys are unique. Demonstrate the replay and conflict results, inspect the stored row, and name the exercise's limits. That explanation gives the interviewer evidence beyond a list of tool names.

        Common questions

        What does a Python backend developer do? A Python backend developer builds and operates server-side software that handles requests, applies business rules, and manages stored data. The work includes tests, code review, releases, and investigating errors after deployment.

        Which Python backend developer skills should I learn first? Start with Python functions, data structures, exceptions, and modules, then learn HTTP and one web framework. Add SQL, transactions, automated tests, and access checks before moving into deployment and more complex architecture.

        Do I need more than one Python web framework? You don't need multiple frameworks for your first backend project. Choose one and demonstrate request validation, database changes, consistent responses, and tests before learning another framework.

        When should I learn asynchronous Python? Learn asynchronous Python after you understand ordinary request handling and have a concrete need to coordinate waiting on network or other input and output operations. Asynchronous programming doesn't automatically speed up CPU-heavy calculations or solve duplicate-request problems.

        Practice what this post teaches

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        New accounts get 12 hours of full access: every course, unit, project and exam. The clock starts when you open your first lesson.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.