# 1 [python3] Simple calculation using variables

Introduction

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.

1 Try a simple calculation

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.

2 Operations using variables

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

At the end

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

# 1 [python3] Simple calculation using variables
Age calculation using python
Python notes using perl-special variables
Initializing global variables using Python decorators
Using global variables in python functions
Start using Python
Scraping using Python
Python memorandum numbering variables
[Python] Get environment variables
Operate Redmine using Python Redmine
Fibonacci sequence using Python
Data analysis using Python 0
Data cleaning using Python
python numpy array calculation
Python --Simple security software
Using Python #external packages
WiringPi-SPI communication using Python
Date calculation in python
Search Twitter using Python
Name identification using python
Notes using Python subprocesses
Date calculation in Python
Try using Tweepy [Python2.7]
Calculation problem using mod
Numerical calculation with Python
Python --Simple multi-thread sample
[Python] [Word] [python-docx] Simple analysis of diff data using python
Derivatives Learned Using Python-(1) Calculation of Forward Exchange Rate-
Python notes using perl-ternary operator
Flatten using Python yield from
Scraping using Python 3.5 async / await
Environment variables when using Tkinter
Save images using python3 requests
Python: Class and instance variables
About Python variables and objects
Calculation time measurement using maf
Using Quaternion with Python ~ numpy-quaternion ~
[Python] Calculation method with numpy
Try using Kubernetes Client -Python-
Shapley value calculation in Python
[Python] Using OpenCV with Python (Basic)
Scraping using Python 3.5 Async syntax
Website change monitoring using python
Handle environment variables in Python
Post to Twitter using Python
Start to Selenium using python
Search algorithm using word2vec [python]
Change python version using pyenv
python: Basics of using scikit-learn ①
Explosive speed! Using Python Simple HTTP Server for kintone development
Create JIRA tickets using Python
Python class variables and instance variables
Instrument control using Python [pyvisa]
Calculation of satellite orbit LST using python (true sun, average sun)
Simple FPS measurement of python
Manipulate spreadsheets locally using Python
Python memo using perl --join
Web scraping using Selenium (Python)
Python Beginner's Guide (Variables / Arrays)
[Python] I tried using OpenPose
[Python] JSON validation using Voluptuous