Running and Quitting

Overview

Teaching: 10 min
Exercises: 0 min
Questions
  • How can I run Python programs?

Objectives
  • Launch the Jupyter Notebook, create new notebooks, and exit the Notebook.

  • Create Markdown cells in a notebook.

  • Create and run Python cells in a notebook.

Python programs are plain text files.

Use the Jupyter Notebook for editing and running Python.

Spyder

You can also use a Python Integrated Development Environment Example Spyder

PyCharm

You can also use a Python Integrated Development Environment PyCharm

Jupyter notebook

Example Jupyter Notebook

Math with numbers

2+3
5
2*2
4
9.81*10.2**2/2
510.3162
3 ** 2
9

Math with strings (?)

"cat " + "dog"
'cat dog'
"cat "*3 + "dog"
'cat cat cat dog'
"cat " - "dog"
...
TypeError: unsupported operand type(s) for -: 'str' and 'str'

Operators

6 + 7
13
6 * 7
42
6 / 7 
0.8571428571428571
6 ** 7 # power
279936
66 % 7  # Modulo (remainder)
3

Logic

6 < 7
True
6 <= 7 
True
6 == 7 
False
6 >= 7 
False
6 > 7 
False
True and False 
False
True or False
True
not False
True

Key Points

  • Python programs are plain text files.

  • Use the Jupyter Notebook for editing and running Python.

  • The Notebook has Command and Edit modes.

  • Use the keyboard and mouse to select and edit cells.

  • The Notebook will turn Markdown into pretty-printed documentation.

  • Markdown does most of what HTML does.