Learn How to Write Python Program Code

Write Python Program Code

Ongkie.com - Once the installation process is complete, then the next step is to run Python itself so that we can start learning to write python program code. On this occasion, you will be reviewed several possibilities to start writing Python program code based on the selection of installation processes that have been done, including:

  1. If you only install Python 3.7.5
  2. If you install Python 3.7.5 + PyCharm IDE
  3. If you only install Anaconda Distribution 2019.10
  4. If you install Anaconda Distribution 2019.10 + PyCharm IDE

If you only install Python 3.7.5

To start writing code programs in Python, you can:

1. Clicking Start Menu, then on its left panel (Programs panel), you scroll down and look for IDLE in the P program group, Python 3.7.5.

2. Click the IDLE icon to open the Python 3.7.5 Shell application.

3. Click the File menu in python 3.7.5 Shell and select New File (Ctrl + N) to open Python 3.7.5 default IDE, as shown below:

Opens python 3.7.5's built-in editor (IDE)
Opens python 3.7.5's built-in editor (IDE)

4. This built-in IDE, as shown by the previous post.


If you installed Python 3.7.5+ PyCharm IDE

If you follow the python 3.7.5 installation process sequence correctly and then the Community version of the PyCharm IDE installation process, Python 3.7.5 is automatically recognized by the PyCharm IDE as its Python interpreter.

To start writing code programs in Python, you can:

1. Clicking Start Menu, then on its left panel (Program panel), you scroll down and look for JetBrains PyCharm Community Edition in program group J, which is JetBrains.

2. Click the JetBrains PyCharm Community Edition icon to open the PyCharm Community application that begins with its splash screen.

PyCharm Community Splash screen
PyCharm Community Splash screen

3. For the first use, will pop up the Import PyCharm Settings From dialog box. Leave it in its default mode and click the OK button.

Import PyCharm Settings From the dialog box
Import PyCharm Settings From the dialog box

4. Next will pop up the PyCharm interface theme selection dialog box and plugins. For now, click the "Skip Remaining and Set Default" button.

PyCharm interfaces theme selection dialog box and plugins
PyCharm interfaces theme selection dialog box and plugins

5. Next, you will find the Welcome to PyCharm dialog box, click Create New Project.

Welcome to the PyCharm dialog box
Welcome to the PyCharm dialog box


6. After you click Create New Project in step 5 will pop up the New Project dialog box. Make a selection, as shown in the image below. Then click the button ... marked by a red box.

New Project dialog box and select set existing interprete
New Project dialog box and select set existing interprete


7. Next, the Add Python Interpreter dialog box will appear, select it in the left pane of System Interpreter with its interpreter, select the one with the Python logo on the author's computer is C:UsersMyPCpython37python.exe, and then click the OK button.

New Project dialog box and select set existing interpreter
New Project dialog box and select set existing interpreter

8. Thus, you return to the New Project dialog box and then click the Create button to create the python project. If you want to change the location of the project directory, you can change it in the Location section.

New Project dialog box with the existing interpreter set selected
New Project dialog box with the existing interpreter set selected


9. After that, you will see the PyCharm IDE Community version window. Please wait until the process of connecting the python interpreter with PyCharm IDE is complete. Click the Close button in the Tip of the Day Dialog box.

Application window PyCharm IDE Community version
Application window PyCharm IDE Community version


10. We will create one python file in the untitled project, right-click on the Untitled Project panel, select New and select Python file. Type the python file name, hello_world, and press Enter.

Creates a single python file in an untitled project
Creates a single python file in an untitled project

Python file name: hello_world
Python file name: hello_world


11. Then, in the editor section, right-click and select Run "hello_world". At the same time, the results can be seen in the image.

Run hello_world.py file
Run hello_world.py file

The run result of the hello_world.py file
The run result of the hello_world.py file


If you only install Ananconda Distribution 2019.10

To start writing program code in Python through the Ananconda Distribution installer, you can:

1. Clicking Start Menu, then on its left pane (Programs pane) you scroll down and search the Ananconda3 folder in program group A.

Anaconda3 from Anaconda Distribution in the Windows 10 Start Menu Program panel
Anaconda3 from Anaconda Distribution in the Windows 10 Start Menu Program panel


Referring to the image above, it appears that there are several icons to start writing Python code in the default application Anaconda3 Distribution, namely:

Anaconda Navigator

Anaconda Navigator can be said to be an application window consisting of 4 tabs.

  1. Tab Home to launch built-in apps like Jupyter Lab, Jupyter Notebook, IDE Spyder, VS Code, R Studio, Orange, etc.
    Home tab on anaconda navigator application window
    Home tab on anaconda navigator application window

  2. Environment tab to manage Python/R environment either create/delete environment; installation, update, or remove Python packages.
    Environment tab in the Anaconda Navigator application window
    Environment tab in the Anaconda Navigator application window

  3. Learning tab to provide links for python learning and its packages.
    Learning Tab in anaconda navigator application window
    Learning Tab in anaconda navigator application window

  4. Community tab provides access to python-related communities/events/forums.
    Community tab in anaconda navigator application window
    Community tab in anaconda navigator application window

Jupyter Notebook

Jupyter Notebook integrates code, text, and visualization on a single page by utilizing browsers like Chrome, Firefox, or Safari. This package is like using Mathematica (commercial application). Jupyter Notebook is a project (project Jupyter) intended as a notebook for all programming languages after changing from IPython Notebook by utilizing Python and IPython as its cores. Another Jupyter project is JupyterLab which extends the capabilities of Jupyter Notebook.

Jupyter Notebook's files directory page
Jupyter Notebook's files directory page


If you start Jupyter Notebook through this start menu or through the Home Tab that also includes JupyterLab, then the top directory is in C:Users'your_pc_name'. If you want to flexible the directory to your liking, then use Anaconda Command Prompt or Anaconda Powershell Prompt.

Spyder 

Spyder as anaconda Distribution's default IDE that has a window-like look of a MATLAB application. For the placement of the directory where the python program you are about to write can be placed to your liking.

Spyder IDE interface display
Spyder IDE interface display


Anaconda Prompt (AP) or Anaconda Powershell Prompt (APsP) – can be said to be a terminal (appropriate on Linux or MacOS) for flexible use of Python and its packages from Anaconda Distribution. This AP or ACsP can launch Anaconda Navigator, Python Shell, IPython console, Spyder, Jupyter Notebook, and Jupyter Lab applications in any directory on your hard drive. In addition, AP or ACsP can manage Python/R environments and packages.

Anaconda Powershell Prompt
Anaconda Powershell Prompt

Anaconda Prompt
Anaconda Prompt


Using IDE Spyder

Spyder can be launched via the start menu in the program panel (Figure 4.14) or through Anaconda Navigator. If through Anaconda Prompt or Anaconda Powershell Prompt, type spyder and press Enter as shown below.

Run spyder application via Anaconda Prompt or Anaconda Powershell Prompt
Run spyder application via Anaconda Prompt or Anaconda Powershell Prompt


For furthermore, you can follow as shown by the figure below.

Spyder interface and main parts
Spyder interface and main parts

Information:

  1. Program code editor.
  2. variable explorer - to view the active variable.
  3. IPython console to run the code file of the program that has been typed.
  4. Toolbar Run to run the program code file that has been typed.
  5. Active Directory where program code files are stored.
  6. To change Active Directory.

Using Jupyter Notebook

Jupyter Notebook can be launched via the start menu in the program panel or Anaconda Navigator or Anaconda Prompt and Anaconda Powershell Prompt. The latter two are much more flexible in creating peak directories wherever python code scripts are stored. For example, I would run a Jupyter Notebook from partition D, in the 004.Activities folder by using the Anaconda Powershell Prompt. Jupyter Notebook documentation can be seen on https://jupyter-notebook.readthedocs.io/en/stable/notebook.html

Running Jupyter Notebook via Anaconda Powershell Prompt or Anaconda Prompt
Running Jupyter Notebook via Anaconda Powershell Prompt or Anaconda Prompt

After that, in your browser default (here using Chrome), on the New button, select Python 3.

Jupyter start page on one of the Chrome tabs
Jupyter start page on one of the Chrome tabs

After Jupyter Notebook appears in the next Chrome tab, you can type in each cell in the form of writing (Markdown cell), python program code, and also display visualization graphs see in the image below.

Jupyter notebook
Jupyter notebook

Information:

  1. The active cell is characterized by a light moss green colored box.
  2. Button to run each cell, or you can press Shift+Enter when the cell is active.

If you want to know more about the features of the Jupyter Notebook interface, please select User Interface Tour from the Help menu.

Jupyter Notebook interface tour
Jupyter Notebook interface tour

Using Jupyter Lab

Same with using Jupyter Notebook, but Jupyter Lab has capabilities that are above Jupyter Notebook. To run Jupyter Lab from partition D, in the 004.Activities folder by using the Anaconda Powershell Prompt. Documentation jupyter Notebook in https://jupyterlab.readthedocs.io/en/stable/user/interface.html

Running Jupyter Lab via Anaconda Powershell Prompt or Anaconda Prompt
Running Jupyter Lab via Anaconda Powershell Prompt or Anaconda Prompt

After that, in your default browser (here using Chrome), in the Notebook section, select Python 3, which is marked with a red box (Figure 4.30).

JupyterLab (Launcher) start page on Chrome tab
JupyterLab (Launcher) start page on Chrome tab

Jupyter lab
Jupyter lab


Information:

  1. The active cell is marked with azuri blue square.
  2. Button to run each cell, or you can press Shift+Enter when the cell is active.


If you install Ananconda Distribution 2019.10 + PyCharm IDE

If you follow the sequence of the Anaconda Distribution 2019.10 installation process (Anaconda3) correctly and then the Community version of the PyCharm IDE installation process, then Anaconda3 is automatically recognized by the PyCharm IDE as its Python interpreter.

At this stage, your IDE options add one, which is PyCharm IDE, in addition to the default Anaconda Distribution as discussed in the previous section.

Reference

All these articles about Python I get from :

https://docs.python.org/3/license.html

https://pypi.org

https://www.python.org/success-stories/

https://www.python.org/dev/peps/pep-0440/#version-scheme

0 Response to "Learn How to Write Python Program Code"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel