Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Scribbler Robots
Hélène Martin
Puget Sound CSTA
April 24th, 2010
Bachelor’s in CS from UW
Career and Technical Ed through South Seattle
Teach at comprehensive public high school
Five periods of computer science
- 2x Exploring Computer Science
- 2x Creative Computing
- 1x AP Computer Science
http://garfieldcs.com
Light-weight syntax
Scalable (small hacks to GUI apps)
Lots of great libraries
- myro (today)
- pygame
- scipy
Interpreted
Permissive
Used increasingly in college courses
Permissive
Dynamically typed (values have types, but not
variables)
Too many ways to skin a single cat!
Not used much in corporate world
- Though YouTube, Google, Yahoo!, NASA make some use of it
Free at http://python.org
Generally pre-installed on OS X or Linux
Includes Idle, an IDE
Arithmetic:
- ** (exponent)
- * (multiplication) / (division) % (modulus)
- + (addition) - (subtraction)
Boolean
- == != < <= > >=
- not
- and or
Common Types
- int, float, bool, str
Indentation matters
1 for i in range(3):
2 print("Hello") # repeated
3 print(25) # repeated
4 print("Hi") # not repeated
Definite loop
Basic for loop structure
1 for i in range(<times>):
2 <statements>
3 <statements>
4 print("Hi") # not repeated
Indefinite loop
While loop strcture
1 while(<condition>):
2 <statements>
3 <statements>
4 print("Hi") # not repeated
Conditional structure
1 if(<condition>):
2 <statements>
3 elif(<condition>):
4 <statements>
5 else:
6 <statements>
Definition
The def keyword is used for defining functions
1 def hello(<param1>, <param2>):
2 print("Hello, world!“)
3
4 hello()
5 hello()
Calling
- A common error is to forget parentheses after the call
http://python.org/
http://diveintopython.org
http://openbookproject.net//thinkCSpy/
def senseLoop():
# getLight() is a function that gives back three values
# Here we save them in three variables.
rightSensor, centerSensor, leftSensor = getLight()