2
2

More than 1 year has passed since last update.

変数のスコープ(Python)

Last updated at Posted at 2023-03-06

Python3の変数のスコープのプログラム例です。

# 変数のスコープ
#  2023/3/6

def get_price(a,b,c):
  # 仮引数 値が代入された変数→ローカル変数
  # 値が代入されていない変数→外のスコープを探す
  # ローカル変数
  total = (a + b + c) * rate
  return format(total,'.0f')

rate = 1.08
print(get_price(300,700,200))

値が代入されていない変数は外のスコープを探します。

2
2
1

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
2
2