Introduction to Python - Stanford University
Introduction to Python
Chris Piech and Mehran Sahami
CS106A, Stanford University
Piech and Sahami, CS106A, Stanford University
Housekeeping
call_me()
You had me at
turn_left()
? Class website:
? Sections
¨C Start this week
¨C If you missed sign-ups, email: cs198@cs.stanford.edu
? LaIR is now open. See class webpage for details
? Bye bye, Karel!
Piech and Sahami, CS106A, Stanford University
More on Programming Style
"""
File: SteepleChaseKarel.py
-------------------------Karel runs a steeple chase that is 9 avenues long.
Hurdles are of arbitrary height and placement.
"""
"""
To run a race that is 9 avenues long, we need to move
forward or jump hurdles 8 times.
"""
def main():
for i in range(8):
if front_is_clear():
Consistent
move()
indentation
else:
jump_hurdle()
Comments for program
and every function
Decomposition principle:
Each function should solve
one step of problem
"""
Pre-condition: Facing East at bottom of hurdle
Post-condition: Facing East at bottom in next avenue after hurdle
"""
def jump_hurdle():
Descriptive names
ascend_hurdle()
(snake_case)
Short functions
move()
descend_hurdle()
(usually 1-15 lines)
Piech and Sahami, CS106A, Stanford University
What¡¯s Mozart Doing Now?
if mehran_teaching():
not_funny()
while mehran_teaching():
not_funny()
Piech and Sahami, CS106A, Stanford University
Welcome to Python
Guido van Rossum
(Creator of Python)
Monty Python¡¯s Flying Circus
Piech and Sahami, CS106A, Stanford University
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- programming principles in python csci 503
- introduction to python programming course notes
- basic python programming for loops and reading files
- how python works
- lesson2 string operations writing scripts
- introduction to python
- python input output and
- a guide to f string formatting in python
- introduction to computers programming input and output
- stanford university jay whang and zach maurer python review
Related searches
- stanford university philosophy department
- stanford university plato
- stanford university encyclopedia of philosophy
- stanford university philosophy encyclopedia
- stanford university philosophy
- introduction to python pdf
- stanford university ein number
- introduction to python programming pdf
- stanford university master computer science
- stanford university graduate programs
- stanford university computer science ms
- stanford university phd programs