8/16/2023
Configuring Python
& Tools
Brandon Krakowsky
Download/Installing Python
• We will be using Python 3 in this course
- There are some differences between Python 3 and Python 2
- If you already have Python 2 installed, please upgrade to Python 3
• To download and install Python, go here: https://www.python.org/downloads/ (Download the
latest version)
• This download/install comes bundled with IDLE (Python’s Integrated Development and Learning
Environment)
- Includes an interactive Python interpreter and script editor
Property of Penn Engineering |
Using IDLE – Running a Python Script
• To create and run a Python script in IDLE, you must first create and save a script file
- Go to “File” --> “New File”
- Go to “File” --> “Save”
• To open an existing script
- Go to “File” --> “Open…”
• To execute a script
- Go to “Run” --> “Run Module”
Property of Penn Engineering |
1
8/16/2023
Using IDLE – Keyboard Shortcuts
• To execute a command in the Python shell
Press Enter
• To execute previous commands
Use CTRL + p or CTRL + n to toggle commands in your history
- To change this default setting, go to IDLE Preferences Keys
• To execute a script in the Python script editor
Press F5
On a Mac, press FN + F5
• To save a script in the Python script editor
Press CTRL + S
On a Mac, press CMD + S
Property of Penn Engineering |
Jupyter Notebook
• Jupyter Notebook App: Runs in a browser on your computer
- Includes interactive Python interpreter and script editor
- To install, download Anaconda, a data science platform. This will install Python and Jupyter
Notebook all at once: https://www.anaconda.com/download (Download the latest version)
- To run, open Terminal on Mac or Command Prompt on Windows and run: jupyter notebook
- Or launch from the Anaconda Navigator
For reference: http://jupyter.org/install.html
Property of Penn Engineering |
Using Jupyter Notebook – Keyboard Shortcuts
• To execute code in a cell in a notebook
Select the cell and press CTRL + Enter
• To execute code in a cell in a notebook, and select the next cell
Select the cell and press Shift + Enter
• To insert a cell above
Select the cell and press a
• To insert a cell below
Select the cell and press b
• To delete a cell
Select the cell and press dd
• To get help with Jupyter Notebook (Keyboard shortcuts)
Anywhere outside of a cell, press h
• To get help with a Python function
Put cursor inside parenthesis of function, and press Shift + Tab
Property of Penn Engineering |
2
8/16/2023
Using Jupyter Notebook – Exporting a Python Script
• To create Python scripts in Jupyter Notebook
- Export a Python script file and save it as <your_script>.py
• Go to “File” --> “Download As” “Python (.py)”
Property of Penn Engineering |
repl.it
• repl.it: Online Python interpreter that runs in the browser
- Includes an interactive Python interpreter and script editor:
https://repl.it/languages/python3
Property of Penn Engineering |
Using repl.it
• Navigate to the Python IDE here: https://repl.it/languages/python3
• This is the Python shell, which allows you to write and run interactive Python commands
Property of Penn Engineering |
3
8/16/2023
Using repl.it
• Navigate to the Python IDE here: https://repl.it/languages/python3
• This is the Python script editor, which allows you to write, run, and save Python scripts
Property of Penn Engineering |
10
Using repl.it – Keyboard Shortcuts
• To execute a command in the Python shell
Press Enter
• To execute previous commands
Use up arrow or down arrow to toggle commands in your history
• To execute a script in the Python script editor
Press CTRL + Enter
On a Mac, press CMD + Enter
• To save a script in the Python script editor
Press CTRL + S
On a Mac, press CMD + S
Property of Penn Engineering |
11
Python Help
• Python Language Resources
- Python Language Reference: https://docs.python.org/3/reference/index.html
- Python Tutorial for Beginners: https://www.w3schools.com/python/
Property of Penn Engineering |
12
4
8/16/2023
Python Help – Other Tools
• Other Python Tools (IDEs)
- PyCharm: Python IDE
- https://www.jetbrains.com/pycharm/download/
- Eclipse with PyDev: Python IDE for Eclipse
- Text Editors: Emacs, VI, Sublime, etc.
Property of Penn Engineering |
13