• Figure B.1: Editing a Python Program
  • Yay! You're now following python programming in your .
  • Here’s an I2C analogue board measuring light levels, with a simple Python program showing the value on a LED bar display.
  • The good news is all that we've learned with the command line GUI can be used in a real Python program!

Python Crash Course: A Hands-On, Project-Based Introduction to Programming


Now we’re ready to begin. Put the mouse cursor on the line of the programwhere we create the turtle screen, and press the F4 key. This will run the Pythonprogram up to, but not including, the line where we have the cursor. Our programwill “break” now, and provide a highlight on the next line to be executed, something like this:

I did our blinken-bar led demo, but with a new twist. We’ve just published the first version of a library for the PCF8591, which is the chip at the heart of our I2C analogue board. We’ve hooked one up to a photocell and written a little Python program to display the light level on a Bar LED. I have to admit to a childish pleasure in seeing the LED respond as I wave my hand above the board.


Anne Dawson: How to Use the ConTEXT editor with Python Programs

Make sure you have started Idle so the current directory is yourPython program directory (for instancein Windows with the downloaded shortcut to Idle).