Appendix C: Python Recipes
Gareth Halfacree · 2017
Python RecipesTHIS APPENDIX CONTAINS complete code listings for the programs detailed in Chapter 7, 'Python', Chapter 8, 'The Wireless BBC micro:bit', Chapter 9, 'The BBC micro:bit and the Raspberry Pi', and Chapter 10, 'Building Circuits', presented without comments to make them easier to type in and compare against.When a line of code would extend past the border of the page, a ↩ symbol is printed.When you see this symbol, continue to type the code without pressing the Enter or Return keys.If you're not sure how a line of code should be entered, visit the website at www.wiley.com/go/bbcmicrobituserguide to download plain-text versions of each program; these can then be used for reference or even simply copy and pasted directly into the editors.Chapter 7: Hello, World! (Non-looping) from microbit import * display.scroll('Hello,World!') Chapter 7: Hello, World! (Looping) from microbit import * while True: display.scroll('Hello,World!') Chapter 7: Button Inputs (Single Button) from microbit import * while True: if button_a.is_pressed():display.show(Image.HAPPY)