0
0

[ Python ] 関数処理

Last updated at Posted at 2024-05-18

■ はじめに

Python勉強につき、メモを残します。
下記内容は、備忘録レベルで書き殴ってますので間違い等あるかもしれません。
参考にする際にはその点ご認識のほどお願いします〜。。

■ 関数

・引数なし関数(戻り値なし)
・引数あり関数(戻り値なし)
・引数あり関数(戻り値あり)

関数処理
# 引数なし関数(戻り値なし)
def message_print():
    print('処理が完了しました。')

# 引数あり関数(戻り値なし)
def arg_message_print(arg):
    print(f'{arg}が完了しました。')

# 引数あり関数(戻り値あり)
TAX = 1.1
def get_tax_calculation(price):
    return int(price * TAX)

 
message_print() #1
print(message_print()) #2
#1 処理が完了しました。(関数呼び出し結果)
#2 処理が完了しました。(関数呼び出し結果)
#2 None(戻り値なしの場合、Noneが返却される)

arg_message_print('評価計算処理') #3 
print(arg_message_print('評価計算処理')) #4
#3 評価計算処理が完了しました。(関数呼び出し結果)
#4 評価計算処理が完了しました。(関数呼び出し結果)
#4 None(戻り値なしの場合、Noneが返却される)

get_tax_calculation(1000) #5
print(get_tax_calculation(1000)) #6
#5 関数呼び出しのみ行なっているためコンソールへの表示はない
#6 1100(戻り値をprint関数で表示)

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