-3

したがって、この童謡は、各行に印刷コードを繰り返すだけでなく、関数を使用して記述する必要があります。歌詞は以下にあり、今までのものも含めました。次に何をすればいいですか?

ハエを飲み込んだおばあさんがいました。
彼女がなぜハエを飲み込んだのかはわかりません。
おそらく彼女は死ぬでしょう。

クモを飲み込んだ
おばあさんがいました。
彼女はハエを捕まえるためにクモを飲み込んだ.
彼女がなぜハエを飲み込んだのかはわかりません。
おそらく彼女は死ぬでしょう。

鳥を飲み込んだおばあさんがいました。
鳥を飲み込むなんてばかげている。
彼女はその鳥を飲み込み、クモを捕まえよ
うとしました。
彼女はハエを捕まえるためにクモを飲み込んだ.
彼女がなぜハエを飲み込んだのかはわかりません。
おそらく彼女は死ぬでしょう。

猫を飲み込んだおばあさんがいました。
猫を飲み込むことを想像してみてください。
彼女は鳥を捕まえるために猫を飲み込んだ。
彼女はその鳥を飲み込み、クモを捕まえよ
うとしました。
彼女はハエを捕まえるためにクモを飲み込んだ.
彼女がなぜハエを飲み込んだのかはわかりません。
おそらく彼女は死ぬでしょう。

犬を飲み込んだおばあさんがいました。
私の、犬を飲み込むなんて豚です。
彼女は猫を捕まえるために犬を飲み込んだ。
彼女は鳥を捕まえるために猫を飲み込んだ。
彼女はその鳥を飲み込み、クモを捕まえよ
うとしました。
彼女はハエを捕まえるためにクモを飲み込んだ.
彼女がなぜハエを飲み込んだのかはわかりません。
おそらく彼女は死ぬでしょう。

馬を飲み込んだおばあさんがいました。
もちろん、彼女は死んでいます。

これまでのところ、私は持っています:

def main():
     title()  # print the title
     verse1() # fly verse
     verse2() # spider verse
     verse3() # bird verse      
     verse4() # cat verse      
     verse5() # dog verse
     lastverse() # horse verse

there was an old lady who swolled a %
# call main
main()
4

1 に答える 1

1
def title():
    text = """
     A children song
    """
    print(text)

def verse1():
    text = """
    There was an old lady who swallowed a fly.
    I don't know why she swallowed the fly.
    Perhaps she'll die.
    """
    print(text)

def verse2():
    text = """
    There was an old lady who swallowed a spider,
    That wriggled and jiggled and tickled inside her.
    She swallowed the spider to catch the fly.
    I don't know why she swallowed the fly.
    Perhaps she'll die.
    """
    print(text)
def verse3():
    text = """
    There was an old lady who swallowed a bird.
    How absurd to swallow a bird.
    She swallowed the bird to catch the spider,
    That wriggled and jiggled and tickled inside her.
    She swallowed the spider to catch the fly.
    I don't know why she swallowed the fly.
    Perhaps she'll die.
    """
    print(text)

def verse4():
    text = """
    There was an old lady who swallowed a cat.
    Imagine that to swallow a cat.
    She swallowed the cat to catch the bird.
    She swallowed the bird to catch the spider,
    That wriggled and jiggled and tickled inside her.
    She swallowed the spider to catch the fly.
    I don't know why she swallowed the fly.
    Perhaps she'll die.
    """
    print(text)
def verse5():
    text = """
    There was an old lady who swallowed a dog.
    My, what a hog, to swallow a dog.
    She swallowed the dog to catch the cat.
    She swallowed the cat to catch the bird.
    She swallowed the bird to catch the spider,
    That wriggled and jiggled and tickled inside her.
    She swallowed the spider to catch the fly.
    I don't know why she swallowed the fly.
    Perhaps she'll die.
    """
    print(text)

def lastverse():
    text = """
    There was an old lady who swallowed a horse.
    She's dead, of course.
    """
    print(text)

def main():
    title()  # print the title
    verse1()  # fly verse
    verse2()  # spider verse
    verse3()  # bird verse
    verse4()  # cat verse
    verse5()  # dog verse
    lastverse()  # horse verse

main()
于 2013-07-19T05:26:46.060 に答える