DDMA Level IIIPython Data Visualisation
Chapters

DDMA Level III

Python Data Visualisation cheat sheet

Every chapter's key points, formulas and definitions on one page, for the last week before the exam. Each heading links to the chapter that explains it.

The Python language

  • Python is a high-level, interpreted language whose readable syntax and large ecosystem of data-focused libraries have made it the dominant language for data science work.
  • Keywords such as if, for and def are reserved words with a fixed meaning; identifiers are the names a programmer chooses for variables and functions.
  • Python uses indentation, not braces, to define blocks of code, so an inconsistently indented block is a syntax error, not just a style problem.
  • A backslash at the end of a line continues a statement onto the next, statements inside brackets can span lines without one, and PEP 8 is the standard style guide.
  • For data acquisition, scrapy builds web scrapers that extract data from websites at scale, while BeautifulSoup parses HTML and XML to pull specific data from a single page.

Key terms

Python version, packages and datasets
Python 3 is the current standard; packages extend the language, and a dataset is the data a program works with.
Keywords and identifiers
Keywords are reserved words with fixed meaning (if, for, def); identifiers are the names a programmer chooses for variables and functions.
Statements and comments
A statement is an instruction Python executes; a comment (starting with #) is ignored by Python, left for human readers.
Data types and variables
A variable holds a value of a given data type, int, float, str, bool, list, dict and others.
Type conversion
Explicitly converting a value from one data type to another, e.g. int('5') to convert text to a whole number.
Input/output and import
input() reads user input, print() writes output, and import brings in a library's functionality.
Arithmetic operators and loops
+, -, *, /, // and % perform calculations; for and while loops repeat a block of code.
Script mode programming
Writing a full program in a .py file and running it, rather than typing commands one at a time.
Python line structure
Python uses indentation, not braces, to define blocks of code, so consistent indentation is not optional.
Joining two lines
A backslash (\) at the end of a line continues a statement onto the next line.
Multi-line statements and indentation
Statements can span multiple lines inside brackets without a backslash; indentation still defines each block's scope.
Python coding style
PEP 8 is Python's standard style guide, consistent naming, spacing and line length, for code that is easy for others to read.
scrapy
A framework for building web scrapers that extract data from websites at scale.
BeautifulSoup
A library for parsing HTML and XML, commonly used to extract specific data from a single scraped page.

The rest of the sheet covers

  • The Python environment
  • Data operations
  • Data visualisation
  • Statistical data analysis
  • Exam technique and revision
  • Glossary