我正在使用python类进行编程的介绍,我们的作业是做99瓶啤酒歌曲。我们还没有学到了很多东西又是那么这的确是所有我能想出:试图在python中编码99瓶啤酒
def StandardVerse():
print n, "bottles of beer on the wall,", n, ",bottles of beer"
print "take one down pass it around,",n,"bottles of beer on the wall."
def TwoBottles():
print "Two bottles of beer on the wall, two bottles of beer."
print "Take one down pass it around, one bottle of beer on the wall."
def OneBottle():
print "One bottle of beer on the wall, One bottle of beer."
print "Take one down, pass it around, no more bottles of beer on the wall."
def NoBottles():
print "No more bottles of beer on the wall, no more bottles of beer."
print "Go to the store, buy some more, 99 bottles of beer on the wall."
for n in range(99,0,-1):
if n > 2:
print StandardVerse
if n == 2:
print TwoBottles
if n == 1:
print OneBottle
if n <= 1:
print NoBottles
它给了我这个当我运行它
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function StandardVerse at 0x027BEC30>
<function TwoBottles at 0x027BEC70>
<function OneBottle at 0x027BECB0>
<function NoBottles at 0x027BECF0>
等多达99瓶(为了空间的缘故,我没有全部复制。)
我该怎么做才能打印出真正的歌曲呢?
如果你要打印函数调用然后返回字符串,否则别pting就叫 –