最赞回答 / weixin_慕村9391395
a = 'python'print('hello,', a or 'world')因为Python把0、空字符串和None看成False。所以a 是true。在计算a or b时,如果 a 是 True,则根据或运算法则,整个计算结果必定为 True,因此返回 a结果:
hello, python...
2022-12-31
最新回答 / 慕用4035794
and 表示与逻辑运算,这种情况下,第一个操作数是True的话,那就看输出结果就取决于第二个数了。这是为什么呢?因为第一个数已经是True了,and 与的运算结果取决于第二个数的真假。
2022-12-28
S=(100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(S.count(100))
print(S.count(100))
2022-12-26
L=[[1,2,3],[5,3,2],[7,3,2]]
for l in L:
a=l[0]
b=l[1]
c=l[2]
S=(a*b+a*c+b*c)*2
print(S)
for l in L:
a=l[0]
b=l[1]
c=l[2]
S=(a*b+a*c+b*c)*2
print(S)
2022-12-23
# Enter a code
S=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
S[0]='Ellena'
S[1]='Alice'
S[2]='Candy'
S[3]='David'
S[4]='Bob'
print(S)
S=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
S[0]='Ellena'
S[1]='Alice'
S[2]='Candy'
S[3]='David'
S[4]='Bob'
print(S)
2022-12-23
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name1=L.pop(2)
name2=L.pop(2)
print(L)
name1=L.pop(2)
name2=L.pop(2)
print(L)
2022-12-23
print(r''''\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.\'''')
2022-12-21
num = 0
L = ['Alice', 66, 'Bob', True, 'False', 100]
for item in L:
num = num + 1
if num % 2 == 0:
print(item)
L = ['Alice', 66, 'Bob', True, 'False', 100]
for item in L:
num = num + 1
if num % 2 == 0:
print(item)
2022-12-18
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
x=input("please input the person you want to check:")
if x in b:
d.pop(x)
print(d)
else:
print('inexistence!!!')
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
x=input("please input the person you want to check:")
if x in b:
d.pop(x)
print(d)
else:
print('inexistence!!!')
2022-12-17
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
s=0
for a in range(5):
if isinstance(T[a], tuple):
s+=1
print(s)
s=0
for a in range(5):
if isinstance(T[a], tuple):
s+=1
print(s)
2022-12-16