先举一个例子:
def eggs_and_bread(eggs_num,bread_pieces):
print "I have %d eggs" %eggs_num
print "I have %d pieces of bread" %bread_pieces
print eggs_and_bread(10,20)
print eggs_and_bread(10+1,20+4)
amout_of_eggs = 100
amout_of_bread =200
print eggs_and_bread(amout_of_eggs,amout_of_bread)
print eggs_and_bread(amout_of_eggs+4,amout_of_bread+8)
注:我们可以在函数里用变量名,我们可以在函数里做运算,我们甚至可以将
变量和运算结合起来;
阅读(1158) | 评论(0) | 转发(0) |