单选题 适中
#18251

执行下面Python代码并输入1和0,输出是( )。 a = int ( input ( ) ) b = int ( input ( ) ) if a and…

执行下面Python代码并输入1和0,输出是( )。

a = int(input())
b = int(input())
if a and b:
	print("1")
elif not (a or b):
	print("2")
elif a or b:
	print("3")
else:
	print("4")


未登录也能判分,登录后才会记录
答案与解析
正确答案:C
解析

a是1,相当与True,b是0,相当于False,那么a and b为False,a or b为True,not(a or b)为False,最终运行的是第三个分支。