LoginSignup
0
0

More than 3 years have passed since last update.

[Python]変数(定義、出力、値変更)

Last updated at Posted at 2020-05-20

変数定義

変数名 = 値
"" は '' でも可能。ただ、"" の方が半角全角の判断がしやすい。
2語以上は _ で区切ると良い。

name = "chikazu"
user_name = "chikazu"

変数の出力

変数の場合は "" 又は `` はつけない。

print(name)

変数値の変更

①price=100 を 200に上書き。
そのまま定義するだけ。

price = 100
print(price)

price = 200
print(price)

②price=100 に数値を演算したものを変数に代入する。
例は + しているが他の四則演算でも可能。
今回は 100+200 で 300が出力される。

price = 100
print(price)

price += 200
print(price)
0
0
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
0