Select an OCR site
Tell us about the qualifications you currently teach, or if you would like to switch to OCR.
Watch our short videos and download factsheets explaining how an exam is created, marked and graded.
I want to
There is lots of talk in the media currently about problem solving and how important it is as a skill to instil in students, especially in Computer Science. That got me thinking about KS4 students and what makes problem solving easier for them in Python.
Once students have become reasonably comfortable with the basics of programming (the techniques in the GCSE specification for example, 2.2 page 10) then they can start to solve problems that involve combining the different techniques to do something tangible.
I have seen the way in which students combine collections of techniques cause some degree of confusion, especially when the problem involves performing a number of different activities at once. To make this easier it is good practice to introduce functional programming as early as possible. I have tried this approach with year 8 students and it made the process of decomposing and solving the problem much simpler as they could put a flowchart or some pseudo-code into a “mini program” that functioned independently and logically did one thing. This technique made the troubleshooting process simpler and made piecing together the different parts of the puzzle easier. The one catch with this technique was that the syntax and process of functions had to be taught up front and the concepts of function scope and parameter passing were vital in the understanding.
Luckily in Python most students will have used functions from very early on using the print() function and so inadvertently already will be familiar with the need for the brackets and an argument. Students may well have also come across other Built In Functions (BIFs) such as input(), len() and help(). Click the link to access the full list:
Initially it is important to get across the concept of what a function is:
Next it needs to be made clear why we should use functions:
It is a good idea to go through the process of creating a simple function and demonstrating how they work, especially using arguments and the scope of variables in a function. It’s also important to make clear the difference between a function and a procedure and the need for a return statement.
Once your students have the hang of these concepts you can get them to look at the code using this web resource: https://inventwithpython.com/chapter6.html and ask them to explain what is happening by drawing a flowchart to explain the process (the answer is on the web-page by the way).
The process of explaining the links between the functions and the logic used is illuminating and uncovers any misunderstandings. This can be extended by getting them to extend the game to involve more choices and of course more functions!
This could be preceded and differentiated by students writing their own functions for things like:
Getting students to think “functionally” from the very beginning makes problem solving simpler and easier to carry out. I have seen some excellent practice in schools using scaffolding to support weaker students and weaning them off the support slowly whilst letting more able students get their hands dirty.
Using our coding challenges booklet candidates can practise solving problems in code until they are experts and these skills can be extended and applied in any real world context to overcome any real world problem.
Please comment below and share your tried and tested techniques using functions to solve computer science problems, you can also follow us on Twitter @OCR_ICT or email us at firstname.lastname@example.org if you have any questions.
Rob Leeman - Subject Specialist - Computer Science