0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

初心者のpythonメモ:演算子

Last updated at Posted at 2019-10-29

#はじめに
本メモはPythonの演算子メモです。

#Pythonの主な演算子
Pythonで数式を入力すると計算をしてくれます

演算子 効果
+ 足し算 1+2=3
- 引き算 5-1=4
* 掛け算 2*3=6
/ 割り算 10/2=5.0
** 累算 2**3=8
% 剰余(割り算の余り) 10%3=1
// 割り算結果を小数点以下無視して整数を返す 5//2=2

#比較演算子と代入演算子
数字の大小を比較する際は、比較演算子を用います。

演算子 数学記号
< < 4<2 False
> > 5>1 True
<= 1<=0 False
>= 3>=3 True
!= 3!=4 True
== = 2==3 False

また、等号(=)は代入演算子、複合代入演算子としても用います。

演算子 説明
= =の左辺の変数に右辺のデータを代入 x=3 xに3を代入
+= +=の左辺の変数に両辺のデータを代入 x+=5 xにx+5を代入
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?