LoginSignup
0
0

More than 3 years have passed since last update.

位置引数、キーワード引数、デフォルト引数

Posted at
argument.py
#desertのデフォルト引数はorange
def menu(drink, food, desert = 'orange'):
    print('drink:', drink)
    print('food:',food)
    print('desert:', desert)

#キーワード引数による関数呼び出し(desertは何も指定していないのでデフォルト引数が渡される)
menu(food ='egg', drink = 'beer')

出力結果:

drink: beer
food: egg
desert: orange
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