Python is the most widely used programming language in Italian technical universities, from engineering to physics by way of data science and bioinformatics. The good news is that you can learn it well in a few weeks, if you follow a sensible progression. The bad news is that 90% of online tutorials start you from the wrong place.
This is the roadmap I use with my students: six weeks, two hours a day, with targeted exercises and direct links to high school maths and physics.
Week 1: the basics of the language
Goal: write your first program and understand what a variable, a type and an expression are.
- Installing Python and an editor (I recommend Visual Studio Code).
- Basic types:
int,float,str,bool. - Arithmetic operators (
+ - * / // % **) and logical ones (and or not). - Input and output with
input()andprint(). - Flow control:
if,elif,else.
Key exercise of the week: write a program that asks the user for the coefficients a, b, c of a quadratic equation and prints the real solutions (or a message if the discriminant is negative). A classic exercise, but it covers everything you have seen.
Week 2: loops and data structures
Goal: understand how to repeat operations and collect data.
whileandfor.- Lists, tuples, dictionaries, sets: what they are and when to use them.
- Indexing and slicing (
list[2:5]). - List comprehensions (
[x**2 for x in range(10)]).
Exercise: given a list of a class’s grades, calculate the average, the highest grade and the number of grades above 6. It is the kind of problem that will show you how much faster Python is than a spreadsheet for certain things.
Week 3: functions and modularity
Goal: write reusable code.
- Defining functions with
def. - Positional and default arguments,
*argsand**kwargs. - Variable scope (local vs. global).
- Multiple return values (
return a, b). - Importing modules (
math,random).
Exercise: write a function solve_quadratic(a, b, c) that returns a tuple with the two solutions (or None if there are no real ones). Then write a function that takes a list of triples and applies the first to all of them. You are building a mini-toolkit.
Week 4: files, errors and scientific libraries
Goal: read data from the real world and use it.
- Reading and writing files (
open,with). - Handling exceptions with
try / except. - Introduction to NumPy: arrays, vectorised operations.
- Introduction to Matplotlib: your first plot.
Exercise: read from a CSV file a series of measurements (for example, position and time of a freely falling object), calculate the average speed between pairs of consecutive points and draw the speed-time graph. This is where Python stops being “a toy” and becomes a tool.
Week 5: applying Python to maths and physics
Goal: use what you know to solve problems from the school syllabus.
- Numerical calculation of derivatives and integrals (Euler’s method, trapezoidal rule).
- Solving equations with the bisection method.
- Simulating the motion of a projectile with air resistance.
- Plotting functions and graphical study of maxima and minima.
A concrete example: simulating the motion of a falling body with dt = 0.01 and Euler integration. In 30 lines you get the trajectory, and you can play with the angle, the initial speed, the friction. When I did this exercise with a Year 4 student, he understood kinematics better than he had in three months at school.
If you want a full overview of what is covered in the computer science course, there is the dedicated page with the programmes I follow.
Week 6: personal project
Goal: apply everything to something that interests you.
Nothing abstract: choose a concrete project. Examples I have assigned:
- A unit converter (forces, energies, pressures) for a physics exam.
- A maths quiz with scoring and a timer.
- A program that downloads and plots the data from a weather station.
- A solver for 3x3 linear systems with Cramer’s method.
The project is the part that lasts. The six weeks of exercises are the pretext for getting here with solid foundations.
Mistakes to avoid in the first weeks
- Skipping the exercises: reading code without writing it teaches nothing.
- Copying without understanding: if you take a solution from Stack Overflow or from an AI assistant, rebuild it line by line.
- Starting with complex frameworks: Django, Flask, machine learning are useful, but not in the first month. Stay on the fundamentals.
- Not reading the errors: Python’s error message almost always tells you where and what went wrong. Read it, don’t close the terminal.
When it makes sense to have a tutor
The problem with learning Python on your own is not the language: it is understanding why a certain solution is good and another is not, why a certain mistake is structural and another is trivial. One lesson a week, even just for the first phase, shortens months of trial and error.
After Python, two topics that take time are functions and parameter passing and the complexity of algorithms. If you want to use it for the web, the next step is HTML and CSS.
If you want to follow this roadmap with someone who corrects your exercises and helps you build the final project, write to me on WhatsApp or through the contact form. I can build you a path adapted to your level and to the time you have.