# Enter a code
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for i in d.keys():
print('{}: {}'.format(i,d[i]))
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for i in d.keys():
print('{}: {}'.format(i,d[i]))
2022-08-21
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
oldResult = d['Alice']
d['Alice'] = 60
print(d)
print(oldResult)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
oldResult = d['Alice']
d['Alice'] = 60
print(d)
print(oldResult)
2022-08-21
# Enter a code
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
d['Alice'] = 60
print(d)
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
d['Alice'] = 60
print(d)
2022-08-21
# 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)
2022-08-21
# Enter a code
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
print(T)
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
print(T)
2022-08-20
# Enter a code
result = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
counts = result.count(100)
print(counts)
result = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
counts = result.count(100)
print(counts)
2022-08-20
# Enter a code
TextTuple = tuple(range(10))
print(TextTuple)
TextList = list(TextTuple)
print(TextList)
TextTuple = tuple(range(10))
print(TextTuple)
TextList = list(TextTuple)
print(TextList)
2022-08-20
# Enter a code
TextTuple = (0,1,2,3,4,5,6,7,8,9)
print(TextTuple)
TextList = list(TextTuple)
print(TextList)
TextTuple = (0,1,2,3,4,5,6,7,8,9)
print(TextTuple)
TextList = list(TextTuple)
print(TextList)
2022-08-20
# coding: utf-8
s=r'''這是一句中英文混合的Python字符串:
Hello World!'''
print(s)
s=r'''這是一句中英文混合的Python字符串:
Hello World!'''
print(s)
2022-08-19
#the first
template='life is {0}, you need {1}.'
result=template.format('short','Python')
print(result)
#the second
template='you need {p}, life is {s}.'
short='short'
Python='Python'
result=template.format(p=Python, s=short)
print(result)
template='life is {0}, you need {1}.'
result=template.format('short','Python')
print(result)
#the second
template='you need {p}, life is {s}.'
short='short'
Python='Python'
result=template.format(p=Python, s=short)
print(result)
2022-08-19
# Enter a code
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for x in L:
length = x[0]
width = x[1]
height = x[2]
result = (length*width+length*height+width*height)*2
print(result)
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for x in L:
length = x[0]
width = x[1]
height = x[2]
result = (length*width+length*height+width*height)*2
print(result)
2022-08-19
# 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)
2022-08-19
# Enter a code
student = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
student.append('Zero')
student.insert(5,'Phoebe')
student.insert(5,'Gen')
print(student)
student = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
student.append('Zero')
student.insert(5,'Phoebe')
student.insert(5,'Gen')
print(student)
2022-08-19
# Enter a code
L = [95.5, 85, 59, 66, 72]
L.sort()
print(L[-1],L[-2],L[-3])
L = [95.5, 85, 59, 66, 72]
L.sort()
print(L[-1],L[-2],L[-3])
2022-08-19
# Enter a code
L = [95.5, 85, 59, 66, 72]
L.sort()
print(L[len(L)-1])
print(L[len(L)-2])
print(L[len(L)-3])
L = [95.5, 85, 59, 66, 72]
L.sort()
print(L[len(L)-1])
print(L[len(L)-2])
print(L[len(L)-3])
2022-08-19