← 返回题目列表

AtCoder · APG4bPython_cp

EX7. 布尔值谜题

中文机器翻译题面 查看原题
#pro

返回说明页面

問題文

在以下程序中声明的 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("")