s1 = {1, 2, 3, 4, 5}
s2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
if not s1.isdisjoint(s2):
s_new = s2 - s1
print(s_new)
else:
print('无重合!')
s2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
if not s1.isdisjoint(s2):
s_new = s2 - s1
print(s_new)
else:
print('无重合!')
2021-01-30
L = ['Alice', 66, 'Bob', True, 'False', 100]
for item in L:
if L.index(item) % 2 != 0:
print(item)
for item in L:
if L.index(item) % 2 != 0:
print(item)
2021-01-30
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
print(s2&s1)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
print(s2&s1)
2021-01-26
# Enter a code
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
d ['Alice']=[50, 61, 66]
d ['Bob'] =[80, 61, 66]
d ['Candy']=[88, 75, 90]
print(d)
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
d ['Alice']=[50, 61, 66]
d ['Bob'] =[80, 61, 66]
d ['Candy']=[88, 75, 90]
print(d)
2021-01-24
# Enter a code
T =(100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print (T.count(100))
T =(100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print (T.count(100))
2021-01-24
L = [[1,2,3], [5, 3, 2], [7,3,2]]
for cube in L:
print (cube)
length = cube[0]
width = cube[1]
heigth = cube[2]
S = length*width*2 + length*heigth*2+width*heigth*2
print(S)
for cube in L:
print (cube)
length = cube[0]
width = cube[1]
heigth = cube[2]
S = length*width*2 + length*heigth*2+width*heigth*2
print(S)
2021-01-24
# Enter a code
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
#89,72,88,79,99
L[0] = 'Ellena'
L[1] = 'Alice'
L[3] = 'Bob'
L[4] = 'David'
print (L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
#89,72,88,79,99
L[0] = 'Ellena'
L[1] = 'Alice'
L[3] = 'Bob'
L[4] = 'David'
print (L)
2021-01-24
# Enter a code
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.pop(2)
L.pop(2)
print(L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.pop(2)
L.pop(2)
print(L)
2021-01-24