Lists

嚜燉ists

Chris Piech and Mehran Sahami

CS106A, Stanford University

Piech + Sahami, CS106A, Stanford University

The Python Console

? Can run Python interactively using the "console"

每 In PyCharm click "Python Console" tab at bottom of window

每 In Terminal, run Python (e.g., typing "py" or "python3" or

"python", depending on your platform) to get console

? Console has prompt: >>>

每 Can type and execute Python statements (and see results)

每 Example:

>>> x = 5

>>> x

5

每 Easy way to try things out to answer questions you may have

每 Use exit() to leave console

Piech + Sahami, CS106A, Stanford University

Let*s Take the Console

Out For a Spin#

Piech + Sahami, CS106A, Stanford University

And Then There Were None

? The term None is used in Python to describe "no value"

每 For example, it is the value you would get from a function

that doesn't return anything

每 WHAT?!

每 Example:

>>> x = print("hi")

>>> print(x)

None

每 Comparing anything to None (except None) is False

? Why does None exist?

每 Denotes when the suitcase for a variable has "nothing" in it

Piech + Sahami, CS106A, Stanford University

Learning Goals

1. Learning about lists in Python

2. Writing code to use lists

3. Understand how lists work as parameters

Piech + Sahami, CS106A, Stanford University

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download