template = 'Life is {a},you need 。'
a1='short'
bp='Python'
result=template.format(a=a1,b=bp)
print(result);
template = 'Life {}。'
result=template.format('is short, you need Python')
print(result)
a1='short'
bp='Python'
result=template.format(a=a1,b=bp)
print(result);
template = 'Life {}。'
result=template.format('is short, you need Python')
print(result)
2020-12-23
a=3.1415926
b='Learn Python in imooc.'
c=100
d=0b1101
print(type(a))
print(type(b))
print(type(c))
print(type(d))
b='Learn Python in imooc.'
c=100
d=0b1101
print(type(a))
print(type(b))
print(type(c))
print(type(d))
2020-12-21
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2020-12-20
l = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for ch in l:
a = ch[0]
b = ch[1]
c = ch[2]
s = 2*(a*b+a*c+b*c)
print(s)
for ch in l:
a = ch[0]
b = ch[1]
c = ch[2]
s = 2*(a*b+a*c+b*c)
print(s)
2020-12-17
L = ['Alice', 66, 'Bob', True, 'False', 100]
i = 1
for ch in L:
i = i+1
if i % 2 == 0:
continue
print(ch)
i = 1
for ch in L:
i = i+1
if i % 2 == 0:
continue
print(ch)
2020-12-16
L = [95.5, 85, 59, 66, 72]
L.sort(reverse=True)
sub_L = L[0:3]
print(sub_L)
L.sort(reverse=True)
sub_L = L[0:3]
print(sub_L)
2020-12-16
3.1415926-------浮點數
'Learn Python in imooc.'-----字符串
100-----整數
0b1101-----二進制數
'Learn Python in imooc.'-----字符串
100-----整數
0b1101-----二進制數
2020-12-15
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
num=0
for key in d.keys():
num=num+1
print(num)
num=0
for key in d.keys():
num=num+1
print(num)
2020-12-11
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
for item in d.keys():
if item=='Alice':
print("old_score:"+str(d['Alice']))
d['Alice']=60
print(d)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
for item in d.keys():
if item=='Alice':
print("old_score:"+str(d['Alice']))
d['Alice']=60
print(d)
2020-12-11