0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

if文

Posted at

if文

py.qiita.py
#  4 if文
#  4-1 
x = 223
if x < 0:
    print('0よりも小さいですよ!')
#     条件分岐
elif x > 0:
    print('0よりも大きいですよ!')
#     else : 上の条件のいずれにも当てはまらない場合
else:
    print('0です!')

FIZZBUZZ問題

py.qiita.py
#  4 -2 FizzBuzz問題
#  3で割り切れる時はFIZZ, 5で割り切れる時はBUZZ, 3と5で割り切れる時はFIZZBUZZを返す
x = 220
#  プログラムは上から順に実行されるので、条件の厳しいものから順に書いていくとよいかもしれない
if x % 15 == 0:
    print('3と5で割り切れるので、FIZZBUZZ')
elif x % 3 == 0:
    print('3で割り切れるので、FIZZ')
elif x % 5 == 0:
    print('5で割り切れるので、BUZZ')
else:
    print(x, 'は割り切れません')
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?