Last active
August 8, 2016 15:33
-
-
Save yumatsuoka/41fab93b22ea544b3aa5746b4a04674c to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/sbin/env python | |
# -*- coding: utf-8 -*- | |
# Fizz_Buzz | |
from __future__ import print_function | |
print("easy ver\n") | |
for i in range(1, 101): | |
if i % 15 == 0: | |
print("fizzbuzz") | |
elif i % 3 == 0: | |
print("fizz") | |
elif i % 5 == 0: | |
print("buzz") | |
else: | |
print(i) | |
print("\n2行er\n") | |
for i in range(1, 101): | |
(print("fizzbuzz")) if (i % 15 == 0) else ((print("fizz")) if (i % 3 == 0) else ((print("buzz")) if (i % 5 == 0) else(print(i)))) | |
print("\nリスト内包表記を使った1行ver\n") | |
print([("fizzbuzz") if (i % 15 == 0) else (("fizz") if (i % 3 == 0) else (("buzz") if (i % 5 == 0) else(i))) for i in range(1, 101)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment