Introduction to Python
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
? Start this week ? 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. """
Comments for program and every function
"""
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):
Decomposition principle:
if front_is_clear(): move()
else: jump_hurdle()
Consistent indentation
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(): ascend_hurdle() move()
Short functions
Descriptive names
(snake_case)
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
- types in python
- python and algorithms
- chapter 1 scalar variables and data types
- lec python intro wellesley college
- cs303e elements of computers and programming simple python
- data types in python
- lecture 2 python data type and variables data data type
- introduction to python
- python essentials documentation
- python input output and variables
Related searches
- introduction to financial management pdf
- introduction to finance
- introduction to philosophy textbook
- introduction to philosophy pdf download
- introduction to philosophy ebook
- introduction to marketing student notes
- introduction to marketing notes
- introduction to information systems pdf
- introduction to business finance pdf
- introduction to finance 15th edition
- introduction to finance books
- introduction to finance online course