|
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 non-commercial 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. | giantLetters2013-3-27.pdf | giantLetters.py |
2 | Compound Interest | Simple Python that features some arithmetic and formatted output. | compoundInterest2013-6-7.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. | lower2upperCase2013-4-9.pdf | lower2upperCase.py |
4 | Swimming Pool | Time to fill swimming pool. Constants, integer input (int(raw_input())), formatted output, use of simple arithmetic operators. | swimmingPool2013-3-27.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. | floatingBarge2013-3-17.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_2013-3-28.pdf | landsGardQuote.py |
Selection | ||||
7 | Power 4 | Simple "linear if". | power4_2013-4-9.pdf | power4.py |
8 | Triangle Recognition | Nested "if-else" statements and test to ensure that input describes a realisable triangle. | triangles2013-3-30.pdf | triangles.py |
9 | Quadrilateral Recognition | Similar to triangle recognition problem (see above), nested "if-else" statements. | quadrilaterals2013-3-30.pdf | quadrilaterals.py |
10 | Calculator | Simple calculator program that uses a sequence of "if-else" statements (elif). | calculator2013-3-30.pdf | calculator.py |
Repetition | ||||
11 | ASCII Character set | Simple "while" loop with counter (and input error check). | asciiCharacterSet2013-3-30.pdf | asciiCharacterSet.py |
12 | Menu Input | Simple "continuous" loop with counter (and more on ASCII code). | menuInput2013-4-5.pdf | menuInput.py |
Using previously created modules (importing modules) | ||||
13 | Pythagoras | Simple example using the sqrt function in the math module. | pythagoras2013-4-8.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. | circleCalculation2013-4-7.pdf | circleCalculation.py |
15 | Projectiles | Physics problem. Example using the trigonometric functions and the radians() function in the math module. | projectiles2013-3-27.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. | cosineFormula2013-3-27.pdf | cosineFormula.py |
17 | Geographic Distance | Example importing own module (pythagorasVerII), builds on solution to Pthagoras peoblem (see above). | geographicDistance2013-3-27.pdf | geographicDistance.py and pythagorasVerII.py |
Lists and Dictionaries | ||||
18 | Distance conversion | Simple application illustrating the use of lists and/or dictionaries. | distanceConversion2013-3-30.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_2013-3-28.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_2013-3-28.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) | summarisationReport2013-4-7.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_2013-4-12.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.