
This www page presents a set of programming exercises, and sample solutions, for (UK) key stages 3 and 4 student. Each problem comprises (for download): (i) a .pdf file presenting the problem and a suggested solution and (ii) an executable .py file. The material (except where otherwise indicated) is the copyright of the University of Liverpool. The material is made available for free for noncommercial use, however I woud appreciate appropriate acknowledgement. Should you choose to make use of any of the material for teaching purposes we would greatly appreciate appropriate acknowledgement. The problems are categorised as follows:
Under eaqch category problems are ordewred according to perceived difficulty.
#  Problem  Description/Notes  .py  

Sequence  
1  Giant Letters  First Python Program, sequence of function calls utilising no input and only simple print string output statements.  giantLetters2013327.pdf  giantLetters.py 
2  Compound Interest  Simple Python that features some arithmetic and formatted output.  compoundInterest201367.pdf  compoundInterest.py 
3  Lower to Upper Case Character Conversion  Simple sequential programme that illustratews the concept of The ASCII code, and makes use of the ord() and chr() built in functions.  lower2upperCase201349.pdf  lower2upperCase.py 
4  Swimming Pool  Time to fill swimming pool. Constants, integer input (int(raw_input())), formatted output, use of simple arithmetic operators.  swimmingPool2013327.pdf  swimmingPool.py 
5  Floating Barge  Determine draft of a barge given given LxBxH. Constants, float input (float(raw_input())), formatted output, use of simple arithmetic operators.  floatingBarge2013317.pdf  floatingBarge.py 
6  Landscape Gardening Quote I  More sophisticate large scale problem (based on a AQA GCSE specimen controlled assessment problem) encompassing issues addressed by the above swimming pool and floating barge problems.  landsGardQuote_2013328.pdf  landsGardQuote.py 
Selection  
7  Power 4  Simple "linear if".  power4_201349.pdf  power4.py 
8  Triangle Recognition  Nested "ifelse" statements and test to ensure that input describes a realisable triangle.  triangles2013330.pdf  triangles.py 
9  Quadrilateral Recognition  Similar to triangle recognition problem (see above), nested "ifelse" statements.  quadrilaterals2013330.pdf  quadrilaterals.py 
10  Calculator  Simple calculator program that uses a sequence of "ifelse" statements (elif).  calculator2013330.pdf  calculator.py 
Repetition  
11  ASCII Character set  Simple "while" loop with counter (and input error check).  asciiCharacterSet2013330.pdf  asciiCharacterSet.py 
12  Menu Input  Simple "continuous" loop with counter (and more on ASCII code).  menuInput201345.pdf  menuInput.py 
Using previously created modules (importing modules)  
13  Pythagoras  Simple example using the sqrt function in the math module.  pythagoras201348.pdf  pythagorasVerI.py and pythagorasVerII.py 
14  Circle Calculation  Calculate area and circumference of circle given radius. Example using the pi constant from the math module.  circleCalculation201347.pdf  circleCalculation.py 
15  Projectiles  Physics problem. Example using the trigonometric functions and the radians() function in the math module.  projectiles2013327.pdf  projectiles.py 
16  Cosine formula  Application of the cosine formula. Example using the trigonometric functions and the radians(), degrees() and pow() functions in the math module.  cosineFormula2013327.pdf  cosineFormula.py 
17  Geographic Distance  Example importing own module (pythagorasVerII), builds on solution to Pthagoras peoblem (see above).  geographicDistance2013327.pdf  geographicDistance.py and pythagorasVerII.py 
Lists and Dictionaries  
18  Distance conversion  Simple application illustrating the use of lists and/or dictionaries.  distanceConversion2013330.pdf  distanceConversionVer1.py (lists) and distanceConversionVer2.py (dictionaries) 
File Handling  
19  Materials Costs Update  Loading data from a text file into a dictionary. Builds on Landscape Gardening Quote I problem (see above)  materialCostUpdate_2013328.pdf  materialCostUpdate.py and the text file newMaterialCosts.txt 
20  Landscape Gardening Quote II  Based on a AQA GCSE specimen controlled assessment problem. Combines solutions to Landscape Gardening Quote I and Materials Costs Update problems.  landsGardQuoteII_2013328.pdf  landsGardQuoteII.py 
21  Summarisation Report  More sophisticated example of loading data from several text files into dictionaries. Builds on Landscape Gardening Quote I problem (see above)  summarisationReport201347.pdf  summarisationReport.py and the text files: (i) quotesToDateFile.txt, (ii) quoteNumber1.txt, (iii) quoteNumber2.txt, (iv) quoteNumber3.txt, (v) quoteNumber4.txt, (vi) quoteNumber5.txt and (vii) quoteNumber6.txt. 
22  Landscape Gardening Quote III  Complete solution to AQA GCSE specimen controlled assessment problem. Extension of solutions to Landscape Gardening Quote II problems Summarisation Report problems.  landsGardQuoteIII_2013412.pdf  landsGardQuoteIII.py and the text files: (i) quotesToDateFile.txt, (ii) quoteNumber1.txt, (iii) quoteNumber2.txt, (iv) quoteNumber3.txt, (v) quoteNumber4.txt, (vi) quoteNumber5.txt and (vii) quoteNumber6.txt. 
Created and maintained by: Frans Coenen.