Free Python tutorial

Learn Python for data analytics, from zero to job-ready

57 free lessons that take you from your first print() to pandas, charts, statistics, APIs, Excel automation and interview questions. Every lesson uses the same Indian grocery-delivery dataset, FreshBasket, and every output on the page comes from actually running the code.

Module 1

Getting Started

  1. 1. What Is Python and Why Do Data Analysts Use It?What is Python and why do data analysts use it? See what it can do next to Excel and SQL, and take a first look at the FreshBasket data.
  2. 2. Setting Up Python, Jupyter and Your First ScriptInstall Python, choose between Jupyter, VS Code and Google Colab, install the data libraries and run your first script step by step.
  3. 3. Variables and Data Types in PythonLearn Python variables, naming rules and the core data types (int, float, str, bool, None) with simple FreshBasket examples.
  4. 4. Numbers and Operators in PythonPython arithmetic, operator precedence, integer division, remainders, rounding and floating-point surprises, using real pricing examples.
  5. 5. Strings in Python: Text Handling for AnalystsCreate, slice, search, clean and format text with Python strings, using customer names, emails and product labels.
  6. 6. Type Conversion, Input and OutputConvert between int, float, str and bool, handle conversion errors, read user input and control how print displays results.

Module 2

Control Flow

  1. 7. Booleans, Comparisons and Logical OperatorsAsk yes/no questions about data with comparison and logical operators, and learn how Python evaluates and, or and not.
  2. 8. Making Decisions with if, elif and elseControl which code runs with if, elif and else, nested conditions, conditional expressions and match, using delivery and pricing rules.
  3. 9. for Loops and range(): Repeating Work AutomaticallyRepeat actions over lists, strings and number sequences with for loops and range(), and build totals, tables and reports step by step.
  4. 10. while Loops, break and continueRepeat code until a condition changes with while loops, and control them with break, continue and else, using stock and retry examples.
  5. 11. Loop Patterns: enumerate, zip, Accumulators and Nested LoopsThe loop patterns analysts use daily: enumerate, zip, reversed, sorted, counting, running totals, filtering and building new lists.

Module 3

Data Structures

  1. 12. Python Lists: Storing and Changing CollectionsCreate, index, slice, modify and sort Python lists, understand mutability and copying, and learn the list methods analysts use most.
  2. 13. Tuples and UnpackingUse tuples for fixed records, unpack values into variables, return several values from functions and know when to pick a tuple over a list.
  3. 14. Python Dictionaries: Key-Value DataStore and look up data by name with dictionaries: create, read, update, loop, count, group, nest and sort, using FreshBasket records.
  4. 15. Python Sets: Unique Values and Set OperationsRemove duplicates, test membership instantly and compare groups with union, intersection and difference, using customer and product examples.
  5. 16. Python Comprehensions: Transform and Filter in One LineBuild lists, dictionaries and sets in one readable expression, with filtering, conditional values, nested loops and generator expressions.

Module 4

Functions

  1. 17. Python Functions: Write Code Once, Use It EverywhereDefine Python functions with def, return values, write docstrings and build small reusable helpers for cleaning and reporting data.
  2. 18. Python Function Arguments: Defaults, Keywords, *args and **kwargsMaster positional and keyword arguments, default values, *args and **kwargs, and avoid the mutable default argument trap.
  3. 19. Python Lambda, map, filter and Custom SortingWrite short anonymous functions with lambda, transform data with map and filter, and sort records by any key or multiple keys.
  4. 20. Python Scope, Closures and RecursionUnderstand local and global scope, build closures that remember values, and write recursive functions with safe base cases.

Module 5

Files, Errors and Modules

  1. 21. Python File Handling: Reading and Writing Text FilesRead and write text files with open and pathlib, use with blocks, process large files line by line and handle encodings and paths.
  2. 22. Python CSV and JSON: Reading and Writing Structured DataRead and write CSV and JSON files with the csv and json modules, handle nested data and convert between the two formats.
  3. 23. Python Errors and Exceptions: try, except, finally and raiseHandle errors gracefully with try, except, else and finally, raise your own exceptions and write data checks that fail clearly.
  4. 24. Python Modules and the Standard Library: datetime, math, random and MoreImport modules, use datetime, math, random, collections and itertools from the standard library, and organise your own code into modules.
  5. 25. Python Classes and Objects: Your First Object-Oriented CodeLearn object-oriented Python: classes, objects, attributes, methods and __init__, with practical FreshBasket examples.
  6. 26. Python Inheritance, Polymorphism and Special MethodsReuse code with inheritance, override methods, use polymorphism and add special methods like __str__ and __eq__ to your classes.

Module 6

NumPy for Analysis

  1. 27. NumPy Arrays: Fast Numerical Computing in PythonCreate NumPy arrays, index and slice them, apply vectorised maths and see why NumPy is faster than Python loops for analysis.
  2. 28. NumPy Broadcasting, Statistics and SimulationUse broadcasting, aggregate along axes, compute statistics and run random simulations with NumPy on FreshBasket-style data.

Module 7

Data Analysis with Pandas

  1. 29. Pandas Series and DataFrames: Your Table ToolkitLoad CSV files into pandas, understand Series and DataFrames, inspect data with head, info and describe, and add new columns.
  2. 30. Pandas Selecting and Filtering: loc, iloc, Masks and querySelect rows and columns with loc and iloc, filter with boolean masks, combine conditions and use query to answer business questions.
  3. 31. Pandas Data Cleaning: Fixing the Messy Orders FileClean a messy orders file: fix types, missing values, duplicates, inconsistent text and outliers, with checks that prove each fix worked.
  4. 32. Pandas groupby: Split, Aggregate and SummariseGroup data with pandas groupby, compute several aggregates at once, use transform and filter, and answer 'by city' style questions.
  5. 33. Pandas merge, join and concat: Combining TablesCombine tables with merge, join and concat, understand inner, left and outer joins, and validate join results to avoid row explosions.
  6. 34. Pandas Dates and Time Series: Resample, Rolling and CohortsWork with dates in pandas: parse, extract parts, resample to months, use rolling windows and build cohort tables.
  7. 35. From SQL to Pandas: A Translation Guide with FreshBasket QueriesA translation guide from SQL to pandas: SELECT, WHERE, GROUP BY, JOIN, window functions and CTEs, each shown side by side.
  8. 36. Pandas Pivot Tables, Reshaping, Strings and applyBuild pivot tables, reshape with melt and stack, use string methods and apply custom functions to transform columns.

Module 8

Data Visualization

  1. 37. Matplotlib Basics: Figures, Axes, Lines and LabelsDraw your first charts with Matplotlib: figures, axes, line plots, titles, labels, legends and saving clean images.
  2. 38. Choosing the Right Chart: Bar, Histogram, Scatter, Box and HeatmapPick the right chart for the question: bar, histogram, scatter, box plot and heatmap, with clear rules and FreshBasket examples.
  3. 39. Seaborn: Statistical Plots in a Few LinesCreate distribution, relationship and category plots with Seaborn in a few lines, and style them consistently.
  4. 40. Visual Storytelling: Building a One-Page KPI Dashboard in PythonTurn analysis into a story: KPI tiles, a multi-chart dashboard layout, clear headlines and exports you can share.

Module 9

Statistics and Exploratory Analysis

  1. 41. Descriptive Statistics: Summarising Data with Mean, Median, Spread and PercentilesSummarise data with mean, median, spread and percentiles in Python, and learn which measure to trust when data is skewed.
  2. 42. Distributions and Outliers: Histograms, Z-Scores and the IQR RuleRead histograms, spot skew, detect outliers with z-scores and the IQR rule, and decide what to do with them.
  3. 43. Correlation: Measuring Relationships Between VariablesMeasure relationships between variables with correlation, read scatter plots and heatmaps, and avoid mistaking correlation for cause.
  4. 44. Sampling, the Central Limit Theorem and Confidence IntervalsUnderstand sampling, the Central Limit Theorem and confidence intervals, and quantify uncertainty with simulations and formulas.
  5. 45. Hypothesis Testing: t-Tests, Chi-Square, ANOVA and A/B TestsRun t-tests, chi-square, ANOVA and A/B tests in Python, read p-values correctly and report results honestly.
  6. 46. Customer Segmentation with RFM Analysis and K-MeansSegment customers with RFM scoring and K-Means clustering in Python, then turn the segments into actions.
  7. 47. Case Study: Explaining Revenue Growth, Step by StepA step-by-step analytics case study: break revenue growth into orders, customers and basket size, and tell the story with evidence.
  8. 48. Regression Basics: Predicting with Linear Models in scikit-learnFit linear regression models with scikit-learn, interpret coefficients, check errors and see honestly when a model has no signal.

Module 10

Text, APIs and Web Data

  1. 49. Regular Expressions: Extracting and Cleaning Text DataExtract and clean text data with Python regex: patterns, groups, findall, sub and verbose patterns, using emails, phones and feedback.
  2. 50. Working with APIs and JSON using requestsCall REST APIs with requests, handle pagination, errors and retries, and turn JSON responses into pandas DataFrames.
  3. 51. Web Scraping with requests and BeautifulSoupScrape web pages with requests and BeautifulSoup: select elements, extract tables, handle missing data and scrape politely.

Module 11

Automation and Reporting

  1. 52. Excel Automation with pandas and openpyxlCreate formatted Excel reports with pandas and openpyxl: formulas, styles, number formats and charts, ready to send.
  2. 53. Automating Files, Logs and Scheduled ReportsAutomate repetitive work: organise files, write logs, build monthly reports with scripts and schedule them to run on their own.

Module 12

Writing Professional Python

  1. 54. Generators, Iterators and DecoratorsProcess big data lazily with generators and iterators, and wrap functions with decorators for timing, logging and caching.
  2. 55. Dataclasses, Type Hints and Clean CodeWrite clearer Python with dataclasses, type hints, naming and small functions, so your analysis code is easy to read and trust.
  3. 56. Testing Your Code with pytestWrite reliable tests with pytest: assertions, parametrize, fixtures, tmp_path and data-quality tests that catch real bugs.
  4. 57. 20 Solved Python Interview Questions for Data Roles20 solved Python interview questions for data roles: core Python, pandas problems on real data, and statistics reasoning.

Ready to test yourself?

Practise with Python interview questions, or pair this tutorial with the free SQL tutorial.

Newsletter

Keep learning Python

One email a week with Python and analytics guides, new practice questions and cohort dates. No spam, unsubscribe anytime.