Python help

Code Novice level help

CC-CodeCards.pdf

Common Syntax Errors (the code does not run due to typo's and grammar mistakes)

Common Syntax Errors

Common example Python code to help with coding tasks

Code Ninja level help

Code Master level help

To be able to attempt the GCSE NEA you need the following Python skills:

  • Input from keyboard

  • Output to display

  • Decisions (IF...THEN...ELSE...)

  • Essential functions: modulus (%), ASC, ORD

  • Use of data types: integer, real, Boolean, character, string, casting

  • String manipulation

  • Common arithmetic operators (+, -, /, *, MOD, DIV)

  • Common Boolean operators (NOT, AND, OR)

  • Pro-Coder Rule #1: Use descriptive names for variables and sub-routines

  • Use of common libraries


To achieve higher than level 4, you will also need the following Python skills:

  • Pro-Coder Rule #2: Convert repeated instructions into loops (condition and counter)

  • Pro-Coder Rule #3: Convert repeated functionality into sub-routines

  • Defensive design considerations: data input sanitation and validation, planning for contingencies, anticipating misuse

  • Arrays or lists

  • Read and write to CSV files

  • A search and sort algorithm


What is the difference between code (up to level 4), and good code (level 5+)?

Good code is:

  • Readable - someone else can understand it

  • Maintainable - code can easily be updated and added to

  • Robust and defensive - code can deal with garbage

MicroPython

CLICK HERE for the online tutorial for coding Python on your MicroBit