L1 = [1,2,3,4,5,6]
t1 = (1,2,3,4,6)
s2 = 'hello word!'
m1 = max(L1)
print(m1)
6
m2 = max(t1)
print(m2)
6
m3 = min(t1)
print(m3)
1
m4 = sum(L1)
print(m4)
21
m5 = max(s2)
print(m5)
w
m6 = min(s2)
print(m6)
J1 = {1,2,3,4,5,6,7,7}
m7 = sum(J1)
print(m7)
28
m8 = min(J1)
print(m8)
1
J2 = {1,'h',2,3,9,'SE'}
z1 = 'I' in s2
print(z1)
False
z2 = 'l' in s2
print(z2)
True
z3 = 'll' in s2
print(z3)
True
z4 = 'lr' in s2
print(z4)
False
z5 = 'SE' in J2
print(z5)
True
a = [1,2,3,4]
b = 'str'
c = {1:4,2:7,3:8,4:9}
print(a)
[1, 2, 3, 4]
del a
print(a)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-25-bca0e2660b9f> in <module>
----> 1 print(a)
NameError: name 'a' is not defined
a = [1,2,3,4];
b = 'str'
c = {1:4,2:7,3:8,4:9}
a
[1, 2, 3, 4]
L = []
L = list()
print(L)
[]
L1 = [1,2,3,4,5,6]
L2 = [1,2,'HE',3,5]
L3 = ['KJ','CK','HELLO']
L4 = [1,4,2,3,8,4,7]
L1.append('H')
print(L1)
[1, 2, 3, 4, 5, 6, 'H']
for t in L2:
L.append(t)
print(L)
[1, 2, 'HE', 3, 5]
L.append(L3)
print(L)
[1, 2, 'HE', 3, 5, ['KJ', 'CK', 'HELLO']]
L3.extend(L4)
print(L3)
['KJ', 'CK', 'HELLO', 1, 4, 2, 3, 8, 4, 7]
L3.count(4)
2
print('L3中4出现的次数为:',L3.count(4))
L3中4出现的次数为: 2
L5 = ['h','h','t','f','h']
print('L5中h出现的次数为:',L5.count('h'))
L5中h出现的次数为: 3
print('L3中HELLO所在的索引为:',L3.index('HELLO'))
L3中HELLO所在的索引为: 2
print('L3中 4 所在的索引为:',L3.index(4))
L3中 4 所在的索引为: 4
print(L5)
['h', 'h', 't', 'f', 'h']
L5.remove('h')
print(L5)
['h', 't', 'f', 'h']
|