EX7 - bool値パズル
Editorial
/
Time Limit: 2 sec / Memory Limit: 1024 MB
問題文
次のプログラムで宣言されている bool 型の変数 a
, b
, c
に対し、True
または False
を代入することで、AtCoder
と出力されるようにしてください。
1, 2, 3 行目における変数 a
,b
,c
への代入以外のプログラムの書き換えは行わないものとします。
プログラム
a = # True または False b = # True または False c = # True または False # ここから先は変更しないこと assert (a is True) or (a is False) assert (b is True) or (b is False) assert (c is True) or (c is False) if a: print("At", end="") else: print("Yo", end="") if not a and b: print("Bo", end="") else: print("Co", end="") if a and b and c: print("foo!", end="") elif True and False: print("year!", end="") elif not a or c: print("der", end="") print("")
入力
この問題に入力はありません
出力
AtCoder
と出力してください。
回答例
答え方の例です。
変数 a
, b
, c
の全てに False
を代入していますが、YoCoder
と出力されているので、この解答は不正解となります。
a = False # True または False b = False # True または False c = False # True または False # ここから先は変更しないこと assert (a is True) or (a is False) assert (b is True) or (b is False) assert (c is True) or (c is False) if a: print("At", end="") else: print("Yo", end="") if not a and b: print("Bo", end="") else: print("Co", end="") if a and b and c: print("foo!", end="") elif True and False: print("year!", end="") elif not a or c: print("der", end="") print("")
出力例
YoCoder
解答例
必ず自分で問題に挑戦してみてから見てください。
クリックで解答例を見る
a = True # True または False b = False # True または False c = True # True または False # ここから先は変更しないこと assert (a is True) or (a is False) assert (b is True) or (b is False) assert (c is True) or (c is False) if a: print("At", end="") else: print("Yo", end="") if not a and b: print("Bo", end="") else: print("Co", end="") if a and b and c: print("foo!", end="") elif True and False: print("year!", end="") elif not a or c: print("der", end="") print("")