T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1, 2, 3, 4, 5))
s = 0
for i in T:
if '(' in str(i):
s+=1
print(s)
s = 0
for i in T:
if '(' in str(i):
s+=1
print(s)
2020-09-20
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
L.remove(a)
else :
continue
S.update(L)
print(S)
print(L)
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
L.remove(a)
else :
continue
S.update(L)
print(S)
print(L)
2020-09-18
这个代码不可以,因为L.pop(2)之后Candy出去了,现在要退学的David是在第二个位置,所以下一个位置还是需要pop(2)
2020-09-18
# Enter a code
# -*- encoding:utf-8 -*-
width=1.57
height=3.14
m3=width*height
m3=round(m3,3)
print("长方形的面积为"+str(m3))
# -*- encoding:utf-8 -*-
width=1.57
height=3.14
m3=width*height
m3=round(m3,3)
print("长方形的面积为"+str(m3))
2020-09-18
# Enter a code
a="python"
print("hello,",a or "world")
b=""
print("hello,", b or "world")
#在计算a or b时,如果 a 是 True,则根据或运算法则,整个计算结果必定为 True,因此返回 a;如果 a 是 False,则整个计算结果必定取决于 b,因此返回 b
a="python"
print("hello,",a or "world")
b=""
print("hello,", b or "world")
#在计算a or b时,如果 a 是 True,则根据或运算法则,整个计算结果必定为 True,因此返回 a;如果 a 是 False,则整个计算结果必定取决于 b,因此返回 b
2020-09-15
ch是在for循环中定义的,意思是把字符串s中的每一个元素依次赋值给ch,然后再把ch打印出来,直到打印出字符串s的最后一个字符为止。
2020-09-15
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
s1=L[0][0]*L[0][1]*L[0][2]
print(s1)
s1=L[0][0]*L[0][1]*L[0][2]
print(s1)
2020-09-10
# Enter a code
L = ['Alice', 66, 'Bob', True, 'False', 100]
i=0
while i<=5:
if i%2!=0:
print (L[i])
i=i+1
L = ['Alice', 66, 'Bob', True, 'False', 100]
i=0
while i<=5:
if i%2!=0:
print (L[i])
i=i+1
2020-09-09
参考答案有问题吧,应该是
hello='Hello'
space=' '
world='World'
print(hello+space +world)
hello='Hello'
space=' '
world='World'
print(hello+space +world)
2020-09-09
L = ['Alice', 66, 'Bob', True, 'False', 100]
for item in L:
i=L.index(item)
if(i%2)!=0:
print(item)
for item in L:
i=L.index(item)
if(i%2)!=0:
print(item)
2020-09-09