From buying a computer to running a program with python

Operating environment

Mac OS Catalina ubuntu

About this article

I was interested in programming and bought a personal computer, but I don't know what to do from now on. For those who don't, here's what to do when you start programming on your Mac. In this article, I wrote a python program for the first time from the state I just bought a personal computer and it works The goal is to be able to do it.

Environment

First, build the environment. Building an environment means preparing to write a program on your personal computer.

The following is required to build a python environment.

I don't need it this time,

I think I'll need this later, so I'll put it together.

Let's put them in order.

Various installations differ depending on whether you are using Mac or ubuntu, so please see the installation method of the one you are using.

VS Code installation

To write and run a program, you need a tool to write the program in the first place. This is called a text editor. VS Code is a kind of text editor and is recommended for beginners because it is easy to use.

Mac

Please download from here

VS Code Official

スクリーンショット 2020-03-18 18.11.38.png

When you click the link, a screen like the image will appear, so click the arrow part It will be downloaded.

Then, I think that it is in the download folder on the mac, so click it to open it.

スクリーンショット 2020-03-22 10.18.46.png

The part indicated by the red arrow is the download folder.

This completes the vscode installation.

ubuntu

Please access here and click the part of the image below to install it.

VS Code Official

Screenshot from 2020-03-22 19-26-38.png

Please return to the home screen when the download is complete. Screenshot from 2020-03-22 19-31-01.png

Open the file

Screenshot from 2020-03-22 19-31-05.png

Select Downloads (or Downloads)

Screenshot from 2020-03-22 19-31-17.png

I think there is a file like a red circle so click on it

Screenshot from 2020-03-22 19-31-22.png

After that, another screen will appear, so enter the password and after a while, the installation will be completed.

Install Python3 (Mac only, skip ubuntu)

Next, install python itself.

On Mac, python2 is included as standard, but the latest python is version 3 or higher, so I will include that.

python official

You can download it by selecting the latest version of python from here and clicking it.

As before, it is in the download folder, so you can download it by clicking it to open it.

installation of jupyter notebook

Next, I will insert the jupyter notebook. This is the same text editor as VS Code, but the specifications and usage are different from VS Code. This time I will just put it in, so I will omit the detailed explanation.

Mac

First, open the terminal. The terminal is like software that can directly instruct the personal computer, and it is in the utility of the application folder.

After opening the terminal, copy and paste the following (You can copy with command + c and paste with command + v while selecting what you want to copy)

pip install jupyter

The installation should complete after a while.

In the same way, if you type the following in the terminal and jupyter notebook starts up in the browser, it is successful.

jupyter notebook

ubuntu

First, open the terminal. A terminal is like software that can directly command a personal computer, and if you press Ctrl, Alt, and T keys at the same time, a black screen will appear. This is the terminal

Screenshot from 2020-03-22 19-48-51.png

Type the following command on that screen.

sudo apt install jupyter-notebook

Then you will be asked for the password, so enter it. The installation will be completed after a while. If you type the following in terminal and the screen appears, it is installed properly.

jupyter notebook

Screenshot from 2020-03-22 20-01-47.png

How to write and execute a program

First, let's write a program. A program is like a collection of instructions to a computer, and the more complicated the instructions, the more instructions there are. A file is a collection of the procedures.

The general order for writing and executing a program is as follows.

  1. Create a file
  2. Write the program of the created file
  3. Execute

Mac

First, create a file to write the program.

Type the following in the terminal

touch test.py

Then open vscode.

After opening vscode, press common + o to open the file you just created. There should be a file named test.py, click it and press Open at the bottom right.

スクリーンショット 2020-03-22 11.00.15.png

Now that the file is open, let's write the program.

You don't have to understand the meaning of the program this time, so copy and paste the following into the file.

print("Hello World!")

Now that the program has been written, save it. (You can save it with command + s.)

Now let's run the program.

Type the following in the terminal:

python3 test.py

Then the result of the program you wrote earlier will be displayed.

ubuntu First, create a file to write the program.

Open terminal (press Ctrl, Alt and T at the same time and a black screen will appear.)

Screenshot from 2020-03-22 19-48-51.png

Type the following on that screen

touch test.py

You now have a file named "test.py".

ls

There is certainly a file named "test.py" when you type in!

Screenshot from 2020-03-22 19-50-39.png

And you can open the screen to edit the file of "test.py" with vscode by typing the following.

code test.py

Now that the file is open, let's write the program.

You don't have to understand the meaning of the program this time, so copy and paste the following into the file. (Since it says print, something seems to be displayed)

print("Hello World!")

Now that the program has been written, save it. You can save it with "Ctrl + S" (Ctrl + S).

Now let's run the program.

Go back to the terminal and type:

python3 test.py

Then the result of the program you wrote earlier will be displayed.

Recommended Posts

From buying a computer to running a program with python
A program to write Lattice Hinge with Rhinoceros with Python
I want to run a quantum computer with Python
Create folders from '01' to '12' with python
How to run a Python program from within a shell script
I wrote a program quickly to study DI with Python ①
How to batch start a python program created with Jupyter notebook
[Python] A program that creates stairs with #
Send a message from Python to Slack
Try to extract a character string from an image with Python3
Read a file in Python with a relative path from the program
Let's create a program that automatically registers ID/PW from CSV to Bitwarden with Python + Selenium
Pass a list by reference from Python to C ++ with pybind11
Everything from building a Python environment to running it on Windows
2. Make a decision tree from 0 with Python and understand it (2. Python program basics)
I tried to create a program to convert hexadecimal numbers to decimal numbers with python
Create a tool to automatically furigana with html using Mecab from Python3
When running a Python shell from Electron, pass multiple arguments to run Python.
Send a message from Slack to a Python server
Edit Excel from Python to create a PivotTable
How to read a CSV file with Python 2/3
Send a message to LINE with Python (LINE Notify)
How to open a web browser from python
Try to draw a life curve with python
I want to make a game with Python
How to generate a Python object from JSON
Try to make a "cryptanalysis" cipher with Python
Decide to assign a laboratory with Python (fiction)
Steps to create a Twitter bot with python
Create a decision tree from 0 with Python (1. Overview)
Try to make a dihedral group with Python
Read line by line from a file with Python
From Python environment construction to virtual environment construction with anaconda
I want to write to a file with Python
A layman wants to get started with Python
Extract data from a web page with Python
Changes from Python 2 to Python 3.0
Try to beautify with Talking Head Anime from a Single Image [python preparation]
WEB scraping with python and try to make a word cloud from reviews
A note I was addicted to when running Python with Visual Studio Code
A memo connected to HiveServer2 of EMR with python
[Python] How to draw a line graph with Matplotlib
Try to make a command standby tool with python
Python Ver. To introduce WebPay with a little code.
Receive dictionary data from a Python program in AppleScript
I tried to draw a route map with Python
I tried running python etc. from a bat file
From python to running instance on google cloud platform
Steps from installing Python 3 to creating a Django app
I want to work with a robot in python.
I tried to automatically generate a password with Python3
[Python] A memo to write CSV vertically with Pandas
Consider a conversion from a Python recursive function to a non-recursive function
Python script to create a JSON file from a CSV file
[Python] How to create a 2D histogram with Matplotlib
[Python] Create a Tkinter program distribution file with cx_Freeze
Using a Python program with fluentd's exec_filter Output Plugin
[Python] How to call a c function from python (ctypes)
How to create a kubernetes pod from python code
[Python] How to draw a scatter plot with Matplotlib
[Python] Road to a snake charmer (5) Play with Matplotlib