1. Variables, Input and Output

What is programming?

A computer is programmed to provide it with a set of instructions to perform. ​

This is achieved by a human using a programming language to write a computer program to tell the computer what to do.​

This produces software, and without it, computers would be a useless collection of hardware.​


Thonny IDE

Software that can be used to write a computer program is known as an IDE.​
IDE stands for Integrated Development Environment.

​The IDE that we will use to write Python code is called Thonny.

The main parts of Thonny are the:

 Code Editor – where you write your code

Shell(run-time environment) – where the user of the program views the output and interacts with it.


Variables

A variable is a named memory location that stores a value which can change during the running of a program.

A variable is can be likened to a box that has a name (identifier) and can store a single value.


Variables in Python

To assign a value to a variable in Python, you give it a name (an identifier) ​
then use an equals sign followed by the value.

Assigning a value to a variable is called declaring a variable.


Outputting the contents of Variables

Output is used to display information to the user.

Once a value has been assigned, the value is held in memory and can then later be used by writing the variable’s name.


The value inside of a variable can change

The value stored inside of a variable can change during the running of a program.​

This happens in sequence.


User Input

User input is used in the programs that you use on an every-day basis.​


User Input in Python

In order to enable to interact with a computer program, user input is used. This is code that prompts the user to enter data, which is then stored inside of a variable. 

Examples of user input in Python are shown below:

When wanting the user to enter an integer (number) then you must code the input function inside of an int() function.