Last active
August 29, 2015 14:23
-
-
Save michitomo/4d7fc2559b9ce32f1e96 to your computer and use it in GitHub Desktop.
課題1‐1: fizz_buzz.py 以下のスクリプトから呼び出す関数fbを書いてください。関数fbは、3で割切れるときはFizz、5で割切れるときはBuzz、両者で割切れるときはFizzBuzzと返してください。ただし、if等の条件分岐構文を使ってはいけません。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fb(i): | |
# http://python.rdy.jp/wiki.cgi?page=FizzBuzz | |
i -= 1 | |
return i%3/2*"Fizz" + i%5/4*"Buzz" | |
i = 1 | |
while i <=20: | |
print i, fb(i) | |
i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment