パイソンサンプルコード 第7回分
サンプル1
home="1月" if home=="1月": print("今は1月です!") else: print("今は1月ではありませんよ!")
サンプル2
x=2 if x==2: print("数値は2です。") if x%2==0: print("数値は偶数です。") if x%2!=0: print("数値は奇数です。")
サンプル3
x=10 y=11 if x==10: if y==11: print(x+y)
サンプル4
home="おやじ" if home=="赤ちゃん": print("こんにちは、赤ちゃん") elif home=="ぼっちゃん": print("こんにちは、ぼっちゃん") elif home=="お兄さん": print("こんにちは、お兄さん") elif home=="おやじ": print("よぉ!おやじ元気か?") else: print("こんにちは、皆さん!")