Quiet…

Because in this article, we will discuss the initial preparation to completion:

  • What is Python and why learn Python?
  • What are the tools needed to learn python?
  • How do I create a python program?
  • What should be learned next?

Let’s discuss it all …

What is Python?

Python is a high-level programming language formulated by Guido van Rossum.

Python is widely used to make various kinds of programs, such as the CLI program, GUI Program (desktop), Mobile Application, Web, IoT, Games, Hacking Programs, etc.

Python is also known as a programming language that is easy to learn because its syntactic structure is neat and easy to understand.

(Python is good for beginners who have never been coding )

Why learn Python?

Ever seen this meme?

Python is indeed very simple compared to other languages. You don’t need this and that to create a Hello World program!

Even the tagline on the website explains if Python will make your work faster and effectively.

Python is a programming language that lets you work quickly and integrate systems more effectively .

So why learn Python?

  1. Fast and effective;
  2. Easy to learn;
  3. Widely used in large companies;
  4. Just curious.
  5. … (add yourself)

Preparation of Tools for Learning Python Programming

What are the tools that must be prepared to learn python programming?

  1. Python: An interpreter that translates python language into machine language, so the program can run.
  2. Text Editor /IDE: The program used to write code.

How do you install Python?

For Linux users, Python does not need to be installed. Because most Linux distributions already provide it by default.

To check it, please type the command python --versionin the terminal.

$ python --version
Python 2.7.12

Python Version 2 vs. Python Version 3

There are two versions of Python currently available, versions 2 and 3.

What’s the difference?

Python version 2 is a version that is widely used today, both in the production and development environment.

While Python version 3 is an advanced development of version 2. Python 3 has more features than Python 2.

To open Python 2 we only use the command python, while Python 3 uses the command python3.

Which should I choose?

For those who are just learning, I recommend using version 2. While for those who are advanced, you can try version 3.

You can also learn more about “HOW TO FIX A SLOW INTERNET PROBLEM WITH YOUR PS4

Prepare Editor Text / IDE for Writing Code

The text editor used to write python programs can be anything. Even Notepad can.

In Linux, there are many choices of text editors that can be used.

Besides the text editor, we can also use the IDE (Integrated Development Environment). However, later we will discuss later.

For now, we only use text editor, so that we understand the concept of programming.

Get to know Python Interactive Mode

Interactive mode is a facility/feature provided by Python as a place to write code interactively.

This feature is also known as Shell, Console, REPL (Read-Eval-Print-Loop) , interpreters, etc.

The way to open interactive mode is to type the command pythonin the terminal.

to exit interactive mode press Ctrldor type the command exit().

Sign >>>, meaning python is ready to take orders.

There is also a sign ...that means the secondary prompt or sub prompt, usually appears when creating a code block and writing a single command in several lines.

Let’s try giving a command print, this command works to print text to the screen.

Try writing print "Hello World"then press Enter.

The command that we write is immediately executed and the results are displayed.

This is an interactive mode, each code or command typed in will be responded directly by python.

We can use this interactive mode to:

  • Testing a function;
  • Specific module experiments;
  • Calculator;
  • Looking for help about certain functions;
  • etc.

The thing we need to try is to look for help with certain functions because it will be very helpful in learning python.

There are two functions that are used to look for help:

  1. function dir()to see what functions are available in a module;
  2. function help()to open the documentation of a function.

As an example, we will try to find out about the use of modules math.

First, we first import the module into interactive mode:

>>> import math

After that, we can look around, what functions are available in the module.

>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan',
 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc',
 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot',
 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow',
 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']

Then, we can find out how to use these functions with help().

Suppose we want to find out how to use a function pow(), then we must give a command help(math.pow).

Help on built-in function pow in module math:

pow(...)
    pow(x, y)

    Return x**y (x to the power of y).
(END)

* to exit documentation press q

After that, we can only use it and try its function.

Programs that we write in interactive mode will not be saved. After the interactive mode is closed, the program will disappear.

Therefore, we have to make scripts.

Please use the text editor to write the script as below.

After that save by name hello_world.py

Then to run the script, use the following command:

python nama_skrip.py

Be sure to type the command in the directory where the script is stored.

Workflow for Making Python Programs

  1. Create a python script with a text editor.
  2. Python script translated into binary code by ( interpreter ) python, so that the computer can understand the meaning of the command.
  3. The computer works on the command.

Understand…?

Up to this point, we already know how to create a Python program.

Next, we will learn how to make the Python program use the PyCharm IDE.

Python Programming Using PyCharm

PyCharm is the best IDE for python programming. PyCharm is made by JetBrains.

There are two versions of PyCharm:

  1. Professional Version ( Trial 30 days) – Has more features for python and web programming.
  2. Community Version (Free and open source ) – Standard feature for python programming.

In this guide, we will use the Community version of PyCharm.

Installing PyCharm on Linux

First, make sure your computer has the JDK (Java Development Kit) or JRE installed. Because PyCharm is made of Java and he needs a JRE to run.

After that…

Please download PyCharm on the JetBrains website.

Make sure to download the community version.

After that, follow the steps below to install it:

  1. Open-File manager as root.
  2. Look for the PyCharm file that was downloaded earlier, then extract it to the directory /opt.In the picture above, I use F3to break the display (depending on the file manager you use).
  3. Reopen the File Manager as a normal user. Then enter /opt/pycharm-community-2017.1.2/bin and double-click on the file pycharm.sh, then select run.
  4. Wait a minute, then a new window will open. Select Don, not import settings, then click OK.
  5. The welcome window will open, please check “Enable opening file …” so that the command is recognized in the terminal. After that click Ok.Enter the password when prompted, then click OK.

Finish …

Try checking on the menu, is there PyCharm or not?

Creating a Python Project on PyCharm

To create a new project, we can click on “Create new Project” in the welcome window (welcome) PyCharm.

Or it can also be done through the File menu -> New Project.

After that, we will be asked to fill in the project name and choose the Python version that will be used.

Just fill the project name with hello-worldand use Python version 2 ( python2.7).

Then we will go directly to the PyCharm work area.

Next, please add the python file by right-clicking on the project directory, then selecting New -> Python File.

After that, give the file name program-pertamaand click Ok.

Next, please write the program code.

print "Hello dunia"
print "Python"
print "Python"
print "Salam,"

Then go to the menu Run -> Run … or press AltShiftF10. If a choice appears, just select it program-pertama.

Congratulations …

If there are questions, please submit via comments!