Category: Python

  • Input (1)

    Input (1)

    Reading input is really important in programming. It means that we can interact with the computer program. There are a number of methods of doing this. Here we will focus on using the Python input function to read input and assign the data entered to a variable. The input function returns a value which is…

  • Variables


    Variables are used to store data and the contents of them can be changed. This could be strings (text), numbers (integers, floats / decimals), or booleans (true or false). Variables must start with a letter. When naming variables (and functions) in Python we use an _ to separate different words. For example a variable to…

  • Fixing Errors (1)

    Fixing Errors (1)

    Try running the program below: There will be a number of errors that are detected when the program runs. The ones here are called syntax errors as they are due to the errors being due to the text we have used in our code. These are different to logic errors which the code will run…

  • Output


    Create a new file in your editor of choice called Enter the code shown below. We are using the print function. You can identify functions in Python as they have ( ) after the function name. The print function takes one or more arguments (stuff inside the brackets). In this example it has one…

  • Introduction


    Python is a high level third generation programming language. Python is an interpreted language as opposed to a compiled language. This means that each line of Python code is executed (run) line by line directly on the computer only at the time the program is run. This is different from a compiled language such ad…

  • Visual Studio Setup for Python

    Visual Studio Setup for Python

    Download and install Python 3 first if it’s not already installed. Once Python is installed restart your computer before moving to the next step. Download Visual Studio Code if you don’t already have it. Open Visual Studio Code Install the Python extension. Click the icon below to access the Extensions tab. Install the Microsoft Python…

  • Python: 15 String Manipulation

    Python: 15 String Manipulation

    W3 Schools Python String Manipulation

  • Python: 14 String Formatting

    Python: 14 String Formatting

    There are a lot of different ways to format and display text in Python. You can find a lot of excellent reference materials on W3 Schools. Using { } inside a string will allow the user to insert the contents form a variable using the format() function. The format function takes any number of arguments…

  • Python: 13 Iteration – Loops – For

    Python: 13 Iteration – Loops – For

    A for loop is used to iterate over a known number of items or a list. It is used when you know how many times the loop will need to run. The loop below will print out all of the items in a list. The indented code will run for each item in the list.…

  • Python: 12 Iteration – Nested Loops

    Python: 12 Iteration – Nested Loops

    Nested loops are loops inside other loops. Note that the outer loop (first_word) is run first and then the code block encounters the second inner loop (second_word). The inner loop is run three times and then moves onto the code below the indented for loop. Then the code block for the outer loop finished and…