This article is written by a fledgling engineer who has been studying programming for about two months for the purpose of output. After biting ruby and js, I became interested in the trend python, so I started learning.
There may be some people saying, "I can understand even if I write this one by one!", But since this is my first post, I will write it as a practice. It's a poor article, but I would appreciate it if you could point out any points that interest you! This article is based on the assumption that python3 and anaconda are installed on macOS.
Start python in the terminal.
$python
It's easy. By the way, if you have not installed anaconda
$python3
It seems to start with.
After the startup is complete, try performing a simple operation.
① ** Addition **
>>> 1 + 1
2
② ** Subtraction **
>>> 1 - 1
0
③ ** Multiplication **
>>> 2 * 2
4
④ ** Division **
>>> 4 / 2
2.0
⑤ ** Too much calculation **
>>> 4 % 3
1
It's easy to understand elementary school mathematics at this level.
It seems that python doesn't need variable declaration and doesn't have type specification. You don't have to remember much!
Immediately, I will assign a value to the variable hoge.
>>>hoge = 2 * 3
>>>hoge
6
2 * 3 is assigned to hoge in the first line, and hoge is output in the second line. Now let's update the value of hoge.
>>>hoge = 2 * 3
>>>hoge
6
>>>hoge = 2 * 20
>>>hoge
40
You can easily change the value of the variable. Now let's calculate using multiple variables.
>>>hoge = 2 * 3
>>>mage = 2 * 20
>>>hoge * mage
240
It is also possible to assign a variable to a variable.
>>>hoge = 2 * 3
>>>mage = 2 * 20
>>>koge = hoge * mage
>>>koge
240
This is the end of this article. I want to make future articles easier to read and understand.
Next article → https://qiita.com/shin12032123/items/543a25bd5777d6e18128
Recommended Posts