A variable is a named location in memory used to store data that can change during program execution. In Python, variables are created by assignment:
Python uses dynamic typing — you don't declare the type; Python infers it automatically.
age and Age are different variablessnake_case for variable names in PythonA constant is a value that does not change during program execution. Python has no built-in constant mechanism, but the convention is to use UPPER_CASE names:
Every value in Python has a data type that determines what kind of data it holds and what operations can be performed on it:
| Data Type | Description | Python Example | Edexcel Pseudocode |
|---|---|---|---|
| Integer (int) | Whole numbers, positive or negative | age = 16 | INTEGER |
| Float (float) | Decimal / real numbers | price = 9.99 | REAL |
| String (str) | Text — sequence of characters in quotes | name = "Alice" | STRING |
| Boolean (bool) | True or False only | logged_in = True | BOOLEAN |
| Char (character) | Single character (Python uses str) | grade = "A" | CHAR |
Type casting (type conversion) converts a value from one data type to another. This is essential when accepting user input (which is always a string):
Common type casting functions: int(), float(), str(), bool()
input() function ALWAYS returns a string. A very common exam question asks you to identify the bug when a student forgets to cast the result of input() to an integer before doing arithmetic.input() returns a string — must cast to int/float for arithmeticTrue/False (Python booleans with capital T/F) with strings8 Edexcel-style questions · instantly marked
age = int(input("Enter your age: ")) [2] — award 1 mark if input() used without int() (type casting missing) or if variable assigned but not cast.score = float(input("Enter score: ")) / 10 or int(input(...)) [1].| Term | Definition |
|---|
Timed exam-style test — 10 minutes.