Python

Constant dripping wears away a stone

IDLE, Visual Studio Code, and Jupyter Notebook


By now you have learned how to install and setup Python. Now let's learn how to enter a Python program into your computer, excute it, and see how the results are displayed. An Integrated Development Environment (IDE) is a kind of software that programmers use to write and run programs. IDLE and Visual Studio Code are two examples of IDEs.
  • IDLE:When you install Python, IDLE will also be installed. For Windows OS, a shortcut to IDLE will be added to your desktop screen. Double click it, the following Python shell window will show up.
    Then click "File" from the main menu of Python shell, then select "New File", you will create a new Python file. Write your Python program. After you are done, save the file with a selected file name in a specific file folder. And then from the main menu of Python shell, select "Run", and then select "Run Module", the output will be displayed in the Python shell window.
  • Visual Studio Code:Visual studio (VS) code is an IDE tool for many programming languages. It is free for use. It can atomatically indent lines, match brackets, and highlight errors in source code. It also provides development support like running and debugging. VS Code can be downloaded fromhttps://code.visualstudio.com. After download and install it, please refer to this link https://code.visualstudio.com/docs/python/python-tutorialto install the Python extension for VS Code. You also need to install Python interpreter from https://www.python.org/downloads/, with the same process discussed in theInstallationpage. Follow the same tutorial https://code.visualstudio.com/docs/python/python-tutorialto create your Python programs.
  • Jupyter Notebook:Jupyter Notebook(https://jupyter.org/)is a web based development environment which has a very flexible interactive interface. You can install it in your local computer together with Python and use the local host. After installing python, you can usepython -m pip install jupyter as a command line in your terminal to install jupyter notebook. To access the notebook, usejupyter notebookas a command line in the terminal. The notebook will then be opened in your default browser. You can put just one line of Python code or put an entire Python program in a cell, and choose to run all the cells at once or only run the current cell. The results will be displayed under the cell(s). To check the version of the jupyter notebook, usejupyter --versionas a command line in your terminal or use!jupyter --versionin your jupyter notebook. To upgrade the jupyter notebook to the latest version, usepip install -U jupyteras a command line in your terminal. To check the python version that jupyter notebooks uses, use!python -V. You can also use an online jupyter notebook platform without installing it in your computer. This website uses both local Jupyter notebook and the online Jupyter Notebook (https://mybinder.org/v2/gh/ipython/ipython-in-depth/HEAD?urlpath=tree/binder/Index.ipynb)for demonstrations.
    After selecting "File"-->"New Notebook"-->"Python 3", a new Jupyter notebook file will show up as the following figure:
    You can then write your code in the cell. When complete, click "Run", then the results will appear under the cell. For example, if you want to print the string "Hello World!", you can putprint("Hello World!")in the cell. Then the output result will be displayed as the following: