Tooltip
These resources have been reviewed and selected by STEM Learning’s team of education specialists for factual accuracy and relevance to teaching STEM subjects in UK schools.

An Introduction to Python (v2.1)

Python is a freely available programming language. This resource contains six sections:

The first section, Getting started, begins with a simple description of how to download and install a Python compiler onto a computer. The screenshots in the resource use a compiler called IDLE. There follow examples of simple programs showing how to print information, input information, perform simple arithmetic and how to include comments in the program.

The second section, Data types, explains how to deal with variables, strings, different kinds of numbers, simple Boolean tests and how to use arrays in the form of lists.

Section three, Control flow, explains how IF, ELSE, ELIF commands are used, how inequalities are used and iterations in the form of WHILE loops, FOR loops and nested loops. Simple procedures are considered with explanations of parameters, outputs from a procedure, optional parameters, use of functions which send data back to the main program in the form of a return and how to import modules.

Section four explores the Turtle environment explaining how to create a turtle, create shapes, use procedures, make a spirograph and how to make and control multiple turtles.

Section five looks at how to import regular expressions and considers their use when checking passwords, validating inputs, using dictionaries, file handling, editing and deleting data.

The final section, Additional exercises begins with straightforward exercises in which users are asked to make a Pythagoras’s calculator, perform primary division, perform arithmetic using random numbers, produce a code maker and a code breaker, a time calculator and simulate an automatic teller machine (ATM). More advanced exercises ask the user to make a prime number tester, perform a binary search, use advanced strings, and perform a bubble sort. The resource concludes by setting some file handling exercises.

This resource was produced by Mark Clarkson.

Show health and safety information

Please be aware that resources have been published on the website in the form that they were originally supplied. This means that procedures reflect general practice and standards applicable at the time resources were produced and cannot be assumed to be acceptable today. Website users are fully responsible for ensuring that any activity, including practical work, which they carry out is in accordance with current regulations related to health and safety and that an appropriate risk assessment has been carried out.

Show downloads

Information on the permitted use of this resource is covered by the Category Three Content section in STEM Learning’s Terms and conditions.

Lists that tag this content