1
Copyright © 2019 by William Lau
Some Rights Reserved. “The Little Book of Algorithms” is licensed under a Creative
Commons Attribution - NonCommercial - ShareAlike 4.0 International License.
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if
changes were made. You may do so in any reasonable manner, but not in any way that
suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your
contributions under the same license as the original.
This summary is located here: https://creativecommons.org/licenses/by-nc-sa/4.0/
ISBN: 978-1-9161163-0-6
For the latest free download of this book, go to http://bit.do/LBOA
Email feedback and corrections to the author: william.lau@computingatschool.org.uk
Twitter: @MrLauLearning
I dedicate this book to my colleagues and students at Central Foundation Boys’
School. You have to be brave to choose (to teach or learn) computer science; it
is not easy and it is not for the faint- hearted!
To Lloyd, Leila, Jaime, Gavin and the brave computer science students at CFBS -
this is for you
Preface……………………………………………………………
1.
Lowest number……………………………………………….
2.
String slicing and concatenation………………………
3.
Area of a circle………………………………….…………….
4.
Odd or even………………………………….………………...
5.
For Loops………………………………………………….…….
6.
While Loops…………………………………………………….
7.
Lowest number in a list…………………………...……...
8.
Linear search………………………………………………….
9.
Linear search in a 2D list…………………………….…..
10. Basic login system……………………………………….....
11. Login system by reading a file………………………….
12. While Loops revisited: Unlimited pin attempts…..
13. Total of a list..….….…………………………………………..
14. Total of a 2D list…..………………………………………….
15. Converting binary to denary…….……………………….
16. Converting denary to binary…….……………………….
17. Challenges…………..………………….………………………
18. Space for further practise and notes….…………….
19. Solutions…………………………………………………………
20. Further reading……………………………………………….
21. Acknowledgements………………………………………….
2
4
6
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
48
53
63
64
2
This book is designed to help teachers and students build fluency in their
Python programming. It is aimed at students who have already been
introduced to the three basic programming constructs of structured
programming, namely sequence, selection and iteration. The original aim
was to help my Year 11 students with their GCSE Computer Science
programming exam. However I hope many students and teachers will find
this book useful. The algorithms are represented using Python as this is a
popular language with a low threshold for learning.
I was inspired to write this book after reading articles by Scott Portnoff,
Sue Sentance and Richard Pawson; three luminaries in the world of
computer science education. All three have made me ask the question,
Dostları ilə paylaş: |