Python for Beginners

Software Development · Beginner · 26 lessons · 8h 12m · Free

By LearnSpace Official

Python for Beginners

About this course

A free, hands-on Python 3 course for complete beginners: install Python, write real programs and build three small projects

A free Python course for people who have never programmed. You will install Python 3, run code in the interactive shell and from script files, and set up a simple editor. Step by step you will learn variables and data types, strings and f-strings, numbers, input and output, conditions and loops, and the core collections: lists, tuples, dictionaries and sets. You will write your own functions, learn to read a traceback calmly and handle errors with try and except, and use the standard library (math, random, datetime, pathlib, json and csv) to work with files. The course also covers virtual environments and pip, and gives you a first look at classes. Every lesson has short examples whose output is shown exactly as Python prints it, plus exercises, and you will build a number-guessing game, a unit converter, a CSV expense summariser and a to-do list saved to JSON. Examples target Python 3.12 and later.

From LearnSpace Official: https://learnspace.io

Enroll for free

Course content

  1. Getting started

    What programming and Python are, how to install Python 3 on Windows, macOS or Linux, how to run code in the interactive shell and from script files, and how to set up an editor and a calm write-run-fix routine.

    1. What programming is and why Python (10m)

      What a program actually is, what makes Python a good first language, where it is used, and how to get the most out of this course even if you have never written a line of code.

    2. Installing Python 3 on Windows, macOS and Linux (15m)

      Install a current version of Python 3 on your computer, open a terminal, and check that everything works. Includes fixes for the most common installation problems.

    3. The interactive shell and your first script (15m)

      Run Python two ways: one line at a time in the interactive shell (the REPL), and as a saved script file. Write and run your first program with print() and comments.

    4. Choosing an editor and a simple workflow (12m)

      Pick a code editor that suits a beginner, learn why indentation matters so much in Python, and set up a calm write-run-fix loop you will use for the rest of the course.

  2. Getting started quiz Quiz

  3. Variables, numbers and text

    How Python stores information: variables and naming, the basic data types and conversions between them, arithmetic and floating-point surprises, strings and f-strings, and reading input from the keyboard.

    1. Variables and data types (15m)

      Store values in variables, name them well, and meet Python’s basic data types: integers, floats, strings, booleans and None. Learn to check a value’s type and convert between…

    2. Working with numbers (15m)

      Do arithmetic in Python: the seven operators, the difference between / and //, remainders with %, powers, order of operations, rounding and why 0.1 + 0.2 is not exactly 0.3.

    3. Strings and f-strings (20m)

      Work with text: quotes and escape characters, indexing and slicing, the most useful string methods, and f-strings for building neat output with formatted numbers.

    4. Input and output (15m)

      Make programs interactive: read what the user types with input(), convert it to numbers, control print() with sep and end, and build a complete tip calculator.

  4. Variables, numbers and text quiz Quiz

  5. Decisions and loops

    Make programs decide and repeat: comparisons and if/elif/else, combining conditions, while loops with break and continue, input validation, for loops with range() and enumerate(), and a complete number-guessing game.

    1. Conditions and if statements (18m)

      Let programs make decisions. Compare values, combine conditions with and, or and not, and choose between actions with if, elif and else.

    2. Repeating with while loops (18m)

      Repeat code while a condition stays true. Write counting loops, stop runaway loops, leave early with break, skip with continue, and keep asking until the user types something…

    3. for loops and range() (20m)

      Repeat code once for each item: loop over strings and lists, count with range(), build totals with the accumulator pattern, number items with enumerate(), and nest loops to make…

    4. Project: a number-guessing game (25m)

      Build a complete game step by step: the computer picks a random number, the player guesses, and the program gives hints, counts attempts, rejects bad input and offers another…

  6. Decisions and loops quiz Quiz

  7. Lists, tuples, dictionaries and sets

    Python’s four core collections: lists for ordered, changing data; tuples for fixed groups and unpacking; dictionaries for looking values up by key; and sets for unique values. Also comprehensions, and how to choose the right collection.

    1. Lists (20m)

      Store many values in one ordered, changeable collection. Create lists, read and change items by index, add and remove items, sort, total and search them, and avoid the copying…

    2. Tuples and unpacking (15m)

      Use tuples for fixed groups of values such as coordinates and records, unpack them into separate variables, swap values in one line, and pair up lists with zip().

    3. Dictionaries (20m)

      Look values up by name instead of position. Create dictionaries, add, change and remove entries, avoid KeyError with get(), loop over keys and values, count things, and store…

    4. Sets, comprehensions and choosing a collection (18m)

      Use sets for unique values and fast membership tests, compare groups with union, intersection and difference, build lists and dicts in one line with comprehensions, and pick the…

  8. Collections quiz Quiz

  9. Functions and errors

    Write your own functions with parameters, return values, defaults and keyword arguments; understand local and global scope; read tracebacks calmly; handle errors with try and except; and build a menu-driven unit converter from small functions.

    1. Defining your own functions (20m)

      Package code into named, reusable functions. Define functions with def, pass in values through parameters, send results back with return, document them with docstrings, and…

    2. Parameters, arguments and scope (20m)

      Make functions flexible with default values and keyword arguments, understand which variables a function can see (local and global scope), avoid the mutable default trap, and add…

    3. Reading error messages and tracebacks (18m)

      Stop fearing red text. Learn the anatomy of a Python traceback, what the most common exceptions mean, and a calm step-by-step method for finding and fixing bugs.

    4. Handling errors with try and except (20m)

      Keep programs running when something predictable goes wrong. Catch specific exceptions with try and except, use else and finally, raise your own errors, and write an input loop…

    5. Project: a menu-driven unit converter (25m)

      Build a complete program out of small functions: a menu, a set of conversion functions stored in a dictionary, a robust number prompt with try/except, and a main loop that ties…

  10. Functions and errors quiz Quiz

  11. Modules, files and projects

    Use the standard library (math, random, datetime, pathlib, json, csv), write your own modules, read and write files, install packages in virtual environments with pip, get a first look at classes, and finish with a CSV expense summariser and a to-do list saved to JSON.

    1. Modules and the standard library (20m)

      Use code that is already written. Import modules in different ways, tour the most useful parts of the standard library (math, random, datetime, statistics, collections), and…

    2. Files, paths, JSON and CSV (25m)

      Make data outlive your program. Work with paths using pathlib, read and write text files safely with with, store structured data as JSON, and read and write spreadsheet-style CSV…

    3. Virtual environments and pip (18m)

      Install third-party packages safely. Create a virtual environment for each project, activate it, install packages with pip, record them in requirements.txt, and fix the most…

    4. A first look at classes (20m)

      Bundle data and the functions that work on it into your own types. Define a class with init and methods, create objects, give them a readable str, and meet dataclasses.

    5. Projects: a CSV expense summariser and a JSON to-do list (35m)

      Finish the course with two complete programs: a report that totals a CSV file of expenses by category, skipping bad rows, and a command-driven to-do list that remembers its tasks…

  12. Modules, files and projects quiz Quiz

Frequently asked questions

How much does Python for Beginners cost?

Python for Beginners is free. Sign up for a free LearnSpace account to enroll and track your progress.

How long is Python for Beginners?

26 lessons, about 8h 12m in total. It's self-paced and online, so you can start and stop whenever you like.

What does Python for Beginners cover?

12 parts: Getting started; Getting started quiz; Variables, numbers and text; Variables, numbers and text quiz; Decisions and loops; and more.

What level is Python for Beginners?

It's marked beginner level in Software Development.

More Software Development courses