Skip to content

Instantly share code, notes, and snippets.

@yumatsuoka
Last active August 8, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumatsuoka/41fab93b22ea544b3aa5746b4a04674c to your computer and use it in GitHub Desktop.
Save yumatsuoka/41fab93b22ea544b3aa5746b4a04674c to your computer and use it in GitHub Desktop.
#!/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