Introduction to Python

The Python programming language is text based and was first created in 1991 by Guido Van Rossum.

It was created as an interpreted language and has a design philosophy of code readability.

Compared to other languages such C and C++, Python is far easier to create and read programs built using it.

It is a general purpose language and can be used to create a large variety of different programs to complete a wide range of tasks, and can be used to accomplish tasks large and small.

Python is intended to be an easy to read language, often omitting the need for Syntax rules found in other languages such as C++ and Java.

During the SKE we covered alot of the basic function within Python, which enabled us to really practice all the necessary skills required to teach it.

With Python you can use many different types of variable, which is piece of data that is able to change as the program runs. This data can be represented in different ways:

  • String – Used for characters with no meaning – Letters or numbers
  • Int – A whole number
  • Float – A decimal number
  • Boolean – True or False

When you wish to use a number for operation or comparison it must be set to an integer. However a number can also be stored as a String, but it is like a page number in a book. It can be identified as a number, but you cannot do anything with it.

Print and Input allow you to get inputs from uses and then print outputs to the display. Moving on from this we covered variables and how to set them from both static but also dynamic content, i.e from inputs.

We also covered the use of various types of Loops. The IF loops allow you use Boolean statements to check if values are True or False, or are Greater, Lower or Equal than, or are set to certain Strings. If they satisfy the criteria, they will perform a certain action, if they do not meet it, then will perform a different action, until it meets it.

While loops allow you to run a loop in a count. So if a variable x is set to 0 and the while loop checks if it is less than 5, it will perform an action, and then increment x each time through the loop until it is 5, then will stop.

Another useful feature of Python is the ability to create lists. This allows you to store data, and recall it as part of the program. The list can be pre-populated with data or it can randomly generate it, or it can append to the list as the program runs.

Python Programming Examples

Below is a few examples of the Python programs I have created during the SKE course.