Python on Raspberry Pi

Uploaded on


More in: Sports , Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • ipython -pylab x = randn(10000) hist(x, 100)


  • 1. Novice Python Programming Workshop Alec Clews t: @alecthegeek b:
  • 2. IntroductionAudience:● Raspberry Pi users who have never programmedObjectives● Write and debug at least one simple program● Want to do more● Know where to go next
  • 3. Short time● Limited material● Simplifications● No OO● Not covering most data types or features
  • 4. Motivation to program● Make our Pi do stuff● Learning is fun!● Solve a problem with a Pi and some Python
  • 5. Why Python?● Clean and simple syntax● Real language● Powerful libraries● Used for desktop, web applications, data munging, computer management and all manner of good things
  • 6. Python Example Desktop App
  • 7. Example Python Web App
  • 8. Other language options?● Go – Lower level modern language● Scratch – Programming visually
  • 9. Python Versions● Python 2.7 ● Modern and supported “production” version● Python < 2.7 ● More widely used● Python 3.x. Probably the Pi default? ● Current almost bleeding edge
  • 10. Lots of Material● Official Python Tutorial● Dive Into Python● Think Python● Learn Python the hard way● Google Python Class● MIT Open Courseware● Python Wiki Book
  • 11. Progamming at the terminal● ls to list directory contents● mkdir to create a directory● rm to delete a file● leafpad to edit a (possibly new) file
  • 12. Supporting Tools● Editor ● Vim or Emacs ● Jedit (X Platform)● Version Control ● Needs another workshop ● Git
  • 13. Next Steps and Resources● Finish the exercises● Scratch your own Pi itch● Attend Melbourne Python Group● Lets start a Project. e.g: ● A game with simple joystick control ● ????
  • 14. Hello World● Using Python IDLE● Hello World Example
  • 15. Programming Overview● Statements – Arithmetic – Input – Output
  • 16. Variables● A box to store numbers and characters e.g.x = 2y = 3answer = x+yprint(answer) 5
  • 17. Type● String “Alec”● Numeric float 123.4● Integer 123● Bool true or false● Complex numbers● List● Other Types ● Tuples ● Dictionary
  • 18. Assignment● Forest of values
  • 19. raw_input()print("Please tell me your name")Please tell me your namename = raw_input()Alecprint("hello " + name)hello Alec
  • 20. Exercise 1Using IDLE create some Python statements that prompt for a name and output a greeting with the name appearing somewhere ● Calculation and expressions ● +-*/ ● ()
  • 21. Exercise 2Take Exercise 1. Add prompt for age and display number of days lived at last birthday (assume no of leap years is age divided by 4)Extension: Prompt for DOB and calculate days lived as at today
  • 22. More Concepts● Structured Data● Decisions
  • 23. Scripts● Chmod + #! line
  • 24. Exercise 3● Take Exercise 1 or 2 and turn into a script file that will run from the command line
  • 25. Loops● while● for
  • 26. Package Code into reusable hunks ● def
  • 27. Exercise 4
  • 28. Exercise 5