Last time I gave an overview of Python. This time, I will explain how to write a program in Python and execute it.
We will also explain how to install the development environment (PyCharm) used when developing Python.
There are two ways to run Python:
--How to use the interactive command line (interpreter format) as if you were entering a command --How to write a program and execute it (we will do it in the next section)
I would like to talk about each of them, but since "how to write a program and execute it" is implemented by preparing a development environment, we will discuss that later.
Let's start with how to use the interactive command line. Please click the URL below.
Then the following screen will appear.
Then click on the red frame below.
Then, after a while, the following screen will be displayed.
In the above, the part where ">>> ■ </ font>" is called ** Python prompt **, and the Python instruction, that is, the program code is executed and input there. I will continue to do it.
The screen for inputting and executing with the keyboard is also called the console.
Now, let's write the program. Write "print ('Hello world!')" At the prompt.
After inputting, press the [Enter] key. Then you can see that it is executed as follows.
Simply put, print is a function, which means that the value in parentheses () of the function is printed to the console.
In addition, Japanese can be used (double-byte characters) in the print function as follows.
In addition to outputting character strings, you can also perform simple numerical calculations.
The above is the execution method using the console.
To do this, you first need to download PyCharm, a Python integrated development environment tool, at the following site:
This section describes how to download and install the tool.
First, click the link below. https://www.jetbrains.com/ja-jp/PyCharm/download/
Then, the following screen will be displayed, so click the [Download] button on the Community side.
Execute the downloaded executable file below.
Then, the following display will appear, so click [Next].
If you want to specify the save location, click [Browse ...] and specify the location. If you don't mind the above, just click [Next].
If you want to create a shortcut on your desktop, check the following points and click [Next].
Just press [Install] to install.
When the installation is complete, the following screen will appear, so click [Finish].
This completes the PyCharm installation.
Finally, start PyCharm. The first time you start it, you will see a screen asking for your consent. When agreeing, check the following points and click [Continue].
Then choose whether to send stats for your development environment to JetBrains or receive improvements from JetBrains. In that case, click [Send Anonymous Statistics] below.
From the next time, the following PyCharm will be launched.
For the first time only, select black background or white background and click [Next: Featured plugins]. (Here, we will proceed with a black background.)
Just press [Start using PyCharm].
Then, the following screen will appear. Select [Create New Project].
Specify the work location of your program. This time, create a folder called ** python ** on the desktop and use that as the work location. After specifying, click [Create].
Then, Python will be installed as shown below. (First time only)
Then the latest information on Python in the development environment will come out. If you want to skip it, press [X].
Now we have described how to install and start PyCharm.
This time, I ran it from the console and checked the result. We also installed PyCharm, which is a development environment. Next time, I would like to explain how to write a program and execute it using PyCharm.
Recommended Posts