Intro to Python
Variables, Loops, Functions, and Your First Real Programs — A TLDR Primer
Staring at a blinking cursor in a Python shell, unsure what def even means? Or maybe you've got a coding class starting Monday and the textbook is a door-stopper full of theory you don't have time for. This guide gets you writing real code fast, without the bloat.
Built for high school and early college students taking their first computer science course — and for parents or tutors who need to get up to speed quickly to help — this primer walks through everything a beginner actually needs: installing Python and running your first script, variables and data types, the operators and expressions that make programs do things, and the control-flow tools (if statements, for loops, while loops) that let a program make decisions and repeat work.
From there it covers the collections you'll use constantly — lists, strings, and dictionaries — along with the indexing and iteration patterns that trip up nearly every new programmer. A full section on functions shows how to structure a program instead of writing one giant block of code, and the final section teaches you to read Python's error messages (tracebacks) instead of fearing them, plus where to go next: files, object-oriented programming, and popular libraries.
This is a python study guide for students who want the concepts explained clearly, with worked examples and common mistakes flagged along the way — concise, to the point, and stripped to essentials so you can start writing programs today instead of next month.
Open it, run your first line of code, and get moving.
- Set up Python and run code from a script and the interactive shell
- Use variables, numbers, strings, and basic input/output confidently
- Control program flow with if-statements, for-loops, and while-loops
- Store and manipulate collections using lists and dictionaries
- Write and call functions, including with parameters and return values
- Read, debug, and extend short Python programs you find in the wild
- 1. Why Python, and How to Run ItOrient the reader to what Python is, why it dominates intro courses, and how to actually get code running on their machine.
- 2. Variables, Types, and ExpressionsIntroduce variables, the core data types (int, float, str, bool), operators, and how Python evaluates expressions.
- 3. Control Flow: if, for, and whileShow how to make decisions and repeat work using conditionals and loops, including indentation rules and common bugs.
- 4. Lists, Strings, and DictionariesCover the two collection types students use most, plus string methods, indexing, and iteration patterns.
- 5. Functions and Program StructureTeach the reader to define functions, use parameters and return values, understand scope, and organize a small program.
- 6. Debugging, Errors, and What to Learn NextShow how to read tracebacks, handle common errors, and point toward next steps like file I/O, OOP, and popular libraries.