DAY 1 - Your First Steps in Python
1.1 What Is Python and Why Should You Care?
Python is a general-purpose programming language created by Guido van Rossum and first released in 1991. The name, in fact, comes not from the snake but from the British comedy series Monty Python's Flying Circus - so you are already in good company.
Python has become the dominant language in data, artificial intelligence and automation for several reasons:
- Readable syntax. Python reads almost like plain English. This means less time deciphering code and more time solving problems.
- Enormous ecosystem. Libraries like pandas, numpy, scikit-learn, TensorFlow and Airflow were all built for Python. Whatever you need to do with data, there is almost certainly a Python tool for it.
- Community. Millions of developers use Python. If you are stuck, someone has already asked your question on Stack Overflow.
- Versatility. The same language is used to clean a spreadsheet, train a neural network, build a data pipeline and automate a business workflow.
You will use Python every single week of your Luxley course. This pre-course gives you the foundations so that Week 1 feels like revision, not a shock.
1.2 Running Python - Your Options
There are two main ways to run Python code, and you will use both during this course.
The Interactive Interpreter (REPL)
Open your terminal (Mac or Linux) or Command Prompt or PowerShell (Windows), type python or python3 and press Enter. You will see something like:
Python 3.11.5 (main, ...)
>>>The >>> prompt means Python is waiting for your input. Type an instruction, press Enter and Python executes it immediately. This is perfect for quick experiments.
>>> 2 + 2
4
>>> print("Hello, Luxley!")
Hello, Luxley!Type exit() to leave the interpreter.
Script Files (.py)
For anything longer than a few lines, you write your code in a file with the .py extension and run it from the terminal:
python my_script.pyDuring this course, use the REPL to test small ideas and .py files for exercises. Your full installation setup is covered in the separate Software Installation Guide.
1.3 Your First Script
Create a file called day1.py and type the following:
print("Hello, world!")
print("My name is Alex.")
print("I am learning Python.")Run it with python day1.py. You should see:
Hello, world!
My name is Alex.
I am learning Python.print() is a function - it takes whatever you put inside the parentheses and displays it on the screen. You will learn much more about functions on Day 5. For now, just know that print() is your main tool for seeing what your programme is doing.
1.4 Comments
A comment is a line that Python ignores completely. It exists purely for humans - to explain what the code does, leave a note or temporarily disable a line.
# This is a comment. Python will not execute this line.
print("This line runs.") # This is an inline comment.
# print("This line is disabled and will not run.")Get into the habit of writing comments from Day 1. Professional code without comments is considered poor practice.
1.5 Variables
A variable is a named container that stores a value. Think of it as a labelled box.
age = 28
name = "Jordan"
height = 1.75
is_student = TrueHere, age, name, height and is_student are variable names. The = sign is the assignment operator - it puts the value on the right into the box on the left. To see what is inside a variable, use print().
Naming rules
Python has strict rules and strong conventions for variable names:
- Must start with a letter or underscore:
name,_temp - Cannot start with a number:
1nameis invalid - Can contain letters, numbers and underscores:
first_name,total2 - Cannot contain spaces or hyphens:
first name,first-name - Case-sensitive:
Ageandageare different variables
By convention, Python variable names use snake_case: all lowercase with underscores between words (first_name, total_score, is_active).
1.6 Basic Data Types
Every value in Python has a type. The four fundamental types are:
- int - integer (whole number)
- float - floating-point number (decimal)
- str - string (text)
- bool - Boolean (
TrueorFalse)
Examples
# int
score = 95
temperature = -3
year = 2025
# float
price = 19.99
average = 4.7
pi = 3.14159
# str
city = "London"
greeting = 'Good morning' # single quotes also work
message = "It's a great day!"
# bool
is_logged_in = True
has_error = FalseStrings can use either single ' or double " quotes, as long as you are consistent within a single string. If your string contains an apostrophe, use double quotes on the outside.
Boolean values are always capitalised in Python: True and False. This is one of the most common early mistakes.
Checking the type of a variable
Use the built-in type() function:
print(type(42)) # <class 'int'>
print(type(3.14)) # <class 'float'>
print(type("hello")) # <class 'str'>
print(type(True)) # <class 'bool'>1.7 A Note on None
Python has a special value called None. It represents the absence of a value - not zero, not an empty string, but genuinely nothing.
result = None
print(result) # None
print(type(result)) # <class 'NoneType'>You will see None frequently in data work when a value is missing or a function does not return anything.
✏️ Day 1 Exercises
Exercise 1.1 - Personal Profile
Create a file called ex1_1.py. Declare the following variables and print each one with a descriptive label:
- Your first name (string)
- Your age (integer)
- Your height in metres (float)
- Whether you have programmed before (boolean)
Hint: use print("Name:", first_name) - when you pass multiple items to print() separated by commas, it prints them with a space between them.
Exercise 1.2 - Type Detective
Create a file called ex1_2.py. Declare five variables of your choice - at least one of each type (int, float, str, bool). Print each variable and its type on the same line using type().
Exercise 1.3 - Challenge: What Happens Here?
Before running the following code, predict what Python will print. Then run it and check.
x = 10
y = x
x = 20
print(x)
print(y)Hint: when you write y = x, Python copies the value of x into y. Changing x afterwards does not affect y.
📌 Day 1 Summary
| Concept | What you learned |
|---|---|
print() | Displays output to the screen |
| Comments | Lines starting with # are ignored by Python |
| Variables | Named containers for storing values |
int | Whole numbers |
float | Decimal numbers |
str | Text, enclosed in quotes |
bool | True or False |
type() | Returns the type of a value |
None | Represents the absence of a value |
Tomorrow you will learn how to manipulate strings, perform calculations and compare values - the building blocks of every data programme you will ever write.