Python Syntax Basics

Erstes ProgrammKommentare

Python has a clean and readable syntax that emphasizes simplicity. Unlike many languages, Python uses indentation to define code blocks instead of braces or keywords.

This lesson covers the core rules you need to write valid Python code.

Indentation – Defining Code Blocks

Python uses spaces (usually 4) to group statements into blocks. Consistent indentation is required.

Wrong indentation causes IndentationError.

Statements and Line Continuation

A statement is a single instruction. Python reads one statement per line, but you can continue with \ or parentheses.

Case Sensitivity

Python is case-sensitive: Name and name are different variables.

Multiple Statements on One Line

Use semicolon ; to separate statements (not recommended for readability).

Best Practices for Syntax

  • Use 4 spaces for indentation (PEP 8 standard).
  • Avoid mixing tabs and spaces.
  • Keep lines under 79 characters when possible.
  • Use parentheses for long expressions instead of \.

Quick Quiz

Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.

✨ Frag Lara — deine KI-Lernpartnerin

Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.


Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

Verfolge deinen Fortschritt 🚀

Lerne einfacher, indem du deinen Fortschritt kostenlos verfolgst.