GCSE Python

Local vs Global Variables, Passing Multiple Parameters, and Returning Multiple Values

Introduction: In Python, understanding how variables are stored and used in functions is important. This page introduces key concepts that help us organise and use data effectively in functions. We’ll look at: Local vs Global Variables: Differentiating between variables defined inside a function (local) and those defined outside (global). Passing Multiple Parameters: How to pass …

Local vs Global Variables, Passing Multiple Parameters, and Returning Multiple Values Read More »

Functions & Parameters

Introduction: In Python, functions are a powerful way to organise and reuse code. They become even more useful when we can pass values to them, allowing the same function to work with different data. These values are passed into the function using parameters and arguments. What is a Parameter? A parameter is a placeholder or …

Functions & Parameters Read More »

Dictionaries (Key-Value Pairs)

Introduction: In Python, a dictionary is a versatile and powerful data structure used to store information as key-value pairs. Unlike lists and tuples that use an index to access elements, dictionaries allow you to access values using unique keys. This makes them an excellent choice for storing and organising data where each piece of information …

Dictionaries (Key-Value Pairs) Read More »

Tuples (Immutable Lists)

Introduction: In Python, a tuple is a type of data structure that is similar to a list, but with one key difference—tuples are immutable. This means that once a tuple is created, you cannot change, add, or remove its elements, whilst the program is running. Tuples are useful when you need to store a collection …

Tuples (Immutable Lists) Read More »

2 Dimensional Lists

Introduction: In Python, we often need to work with more complex structures than simple lists. One such structure is a 2D list, also called a matrix. A 2D list is essentially a list of lists, allowing you to organise data in rows and columns, much like a table or spreadsheet. In other programming languages, a …

2 Dimensional Lists Read More »

Error Handling with try-except

Introduction: In programming, errors (or exceptions) are common, especially when dealing with user input or unexpected situations. Python provides a useful tool called try-except to handle these potential errors without crashing the program. Using try-except, we can anticipate problems in certain sections of our code and respond gracefully. Instead of the program stopping when an …

Error Handling with try-except Read More »

Scroll to Top