Python for Absolute Beginners

Lesson 1 of 6

Getting Started with Python

Python is one of the most popular programming languages in the world, and one of the friendliest for beginners. It's used for everything from web apps and automation scripts to data science and AI.

Your first program

Pythonshares state with other Python blocks

Reading it line by line

  • print(...) writes text to the console, it's usually the very first thing anyone learns in any language.
  • name = "student" creates a variable, a named container for a value, Python figures out the type (here, a piece of text) automatically, you never have to declare it up front.
  • xp += 10 is shorthand for xp = xp + 10, add 10 to whatever xp already is.
  • f"{name} has {xp} XP" is an f-string, the f right before the quotes lets you embed variables directly inside { }, without it you'd have to write something clunkier like name + " has " + str(xp) + " XP".

No semicolons, no braces

Unlike many languages, Python doesn't use { } to mark where a block of code starts and ends, it uses indentation (consistent spaces at the start of a line) instead. Get the indentation wrong and Python refuses to run your code, that's a feature, not a bug, it forces code to stay readable.

TIP

Comments start with # and are ignored when the program runs, use them to explain why you did something, not just what the code does.

📝 Python Basics Quiz

Passing score: 70%
  1. 1.How does Python define code blocks?

  2. 2.The built-in function to display output to the console is ____().