Basics of Python
- philroycrypto
- Mar 9
- 3 min read

I wanted to collate a beginner's list of the key concepts in Python, for reference and future study. Here is is:
Variables (used to store data) and Data types
Operators (Arithmetic, Comparison, Logical, Assignment, Membership, Identity)
Control flow- for decision making
Loops (Iteration)
Functions- for reusable blocks of code
Lists and Tuples (Collections)
Dictionaries and Sets
File Handling- reading and writing files
Exception handling
Object-Oriented Programming
Modules and Libraries- built in and third party
A Variable is a named storage location that holds a value. It means you can store, retrieve and manipulate data. They're created automatically when you assign a value to them and Python dynamically types variables.
Python has several built in Data Types; numeric, string type (a sequence of character enclosed in quotes), Boolean data types (true or false), Sequence data types, Dictionary (key value pairs) and Set (unordered unique items).
Operators are special symbols that perform operations on variables and values:
Arithmetic Operators: Used for mathematical calculations.
Comparison Operators: Compare values and return True or False.
Logical Operators: Combine multiple conditions.
Assignment Operators: Modify and assign values.
Bitwise Operators: Work on bits of numbers.
Identity Operators: Check object identity.
Membership Operators: Check for existence in a sequence.
3. Control Flow refers to the order in which individual statements, instructions or functions are executed in a program. Three main types:
Conditional Statements (if, elif, else)
Loops (for, while)
Loop Control Statements (break, continue, pass)
else Clause in Loops
Nested Loops
Match-Case Statement (Python 3.10+)
4. Loops (Iteration) allow the execution of a block of code multiple times. The two main types are 'for' and 'while' Loops. There are also Loop control statements like 'break', 'continue' and 'pass' to modify loop execution.
for Loop - iterates over sequences
while Loop - runs while a condition is true
break - stops the loop
continue - skips the current iteration
pass - placeholder, does nothing
else in Loop - runs after loop completes normally
Nested loops - a loop inside another loop
enumerate( ) - adds an index while iterating
zip ( ) - loops through multiple sequences together
5. Functions are reusable blocks of code that perform a specific task. They organise code, avoid repetition and improve readability.
There are a number of built in functions.
6. Lists and Tuples are sequence data types that allow storing multiple items in a single variable. Commonly used for grouping related data.
A list is an ordered, mutable collection of elements
A tuple is an ordered, immutable collection of elements
Use lists when you need a modifiable collection, us tuples when you need an unchangeable sequence
Dictionaries and Sets are unordered collection data types in Python.
Dictionaries (dict) store data in key value pairs. Are mutable, ordered and useful for structured data
Sets (set) store unique, unordered elements. Are unique, and great for removing duplicates
File Handling allows you to read, write and and manipulate files, using built in functions which can be learnt and referred to.
Exception Handling allows a program to deal with errors without crashing. Python provides the try-except block to catch and handle errors.
Object-Oriented Programming is a paradigm that organises code into objects that contain data (attributes) and behaviour (methods)
Modules and Libraries help organise code and enable reusability by grouping related functions, classes and variables.
A module is a Python file that contains functions, classes or variables
You can use external libraries
It's worth having an overview of the key topics and terms before diving into the study



Comments