L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for item in L:
if item in S:
S.remove(item)
print(S)
S = set([1, 3, 5, 7, 9, 11])
for item in L:
if item in S:
S.remove(item)
print(S)
2024-02-04
name_set = set()
name1 = (['Jenny', 'Ellena', 'Alice', 'Candy', 'David', 'Hally', 'Bob', 'Isen', 'Karl'])
name_set.update(name1)
print(name_set)
name_set2 = set()
for item in name1:
name_set2.add(item)
print(name_set2)
name1 = (['Jenny', 'Ellena', 'Alice', 'Candy', 'David', 'Hally', 'Bob', 'Isen', 'Karl'])
name_set.update(name1)
print(name_set)
name_set2 = set()
for item in name1:
name_set2.add(item)
print(name_set2)
2024-02-04
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
name_set2 = set()
for name in name_set:
name_set2.add(name.lower())
print('bob'.lower() in name_set2)
name_set = set(names)
name_set2 = set()
for name in name_set:
name_set2.add(name.lower())
print('bob'.lower() in name_set2)
2024-02-04
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
num = 0;
for value in d.values():
for item in value:
num += 1
print(num)
num = 0;
for value in d.values():
for item in value:
num += 1
print(num)
2024-02-04
T = (1, 'CH', [3, 4])
l = list(T)
l[2] = tuple(l[2])
t2 = tuple(l)
print(t2)
l = list(T)
l[2] = tuple(l[2])
t2 = tuple(l)
print(t2)
2024-02-03
t = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(t.count(100))
print(t.count(100))
2024-02-03
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for item in L:
s1 = 2* (item[0]*item[1]+item[1]*item[2]+item[0]*item[2])
print(s1)
for item in L:
s1 = 2* (item[0]*item[1]+item[1]*item[2]+item[0]*item[2])
print(s1)
2024-02-03
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
s = [89, 72, 88, 79, 99]
ls = []
r = []
i = 0
for item in L:
ls.append([item,s[i]])
i += 1
s.sort(reverse=True)
for item in s:
for score in ls:
if score[1] == item:
r.append(score[0])
print(r)
s = [89, 72, 88, 79, 99]
ls = []
r = []
i = 0
for item in L:
ls.append([item,s[i]])
i += 1
s.sort(reverse=True)
for item in s:
for score in ls:
if score[1] == item:
r.append(score[0])
print(r)
2024-02-03
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.pop(2)
L.pop(2)
print(L)
L.pop(2)
L.pop(2)
print(L)
2024-02-03
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(5,'Gen')
print(names)
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(5,'Gen')
print(names)
2024-02-03
L = [95.5, 85, 59, 66, 72]
L.sort(reverse=False)
print(L[-1],L[-2],L[-3])
L.sort(reverse=False)
print(L[-1],L[-2],L[-3])
2024-02-03
L = [95.5, 85, 59, 66, 72]
L.sort(reverse=True)
print(L[0:3])
L.sort(reverse=True)
print(L[0:3])
2024-02-03
L = ['Alice', 66, 'Bob', True, 'False', 100]
num = 0
for item in L:
if num%2==0:
print(item)
num = num+1
else:
num = num +1
num = 0
for item in L:
if num%2==0:
print(item)
num = num+1
else:
num = num +1
2024-02-03
scores = ['Chinese',92,'Math',75,'English',99]
print(scores)
print(scores)
2024-02-03
# Enter a code
s1='ABC'
s2='123'
s3='xyx'
for x in s1:
for y in s2:
for z in s3:
print(x + y + z)
s1='ABC'
s2='123'
s3='xyx'
for x in s1:
for y in s2:
for z in s3:
print(x + y + z)
2024-02-03