>>> num=3.14*1.57
>>> print(num)
4.9298
>>> round(num,2)
4.93
我就这样写的
>>> print(num)
4.9298
>>> round(num,2)
4.93
我就这样写的
2021-01-05
template='Life is short,you need {}'
python='python'
result=template.format(python)
print(result)
python='python'
result=template.format(python)
print(result)
2021-01-01
# coding: utf-8
score = 95
if score < 60:
print('抱歉,考试不及格')
elif score >= 90:
print('恭喜你,拿到卓越的成绩')
elif score >= 80:
print('恭喜你,拿到优秀的成绩')
else:
print('恭喜你,考试及格')
score = 95
if score < 60:
print('抱歉,考试不及格')
elif score >= 90:
print('恭喜你,拿到卓越的成绩')
elif score >= 80:
print('恭喜你,拿到优秀的成绩')
else:
print('恭喜你,考试及格')
2020-12-31
names=['Alice','Bob','Candy','David','Ellena']
name_set=set(names)
for i in name_set:
name=i.lower() #lower首字母小写
names.append(name)
name_set=set(names)
if 'alice' and 'bob' and 'Bob' in name_set:
print(True)
else:
print(False)
name_set=set(names)
for i in name_set:
name=i.lower() #lower首字母小写
names.append(name)
name_set=set(names)
if 'alice' and 'bob' and 'Bob' in name_set:
print(True)
else:
print(False)
2020-12-24
L = [95.5, 85, 59, 66, 72]
n=len(L)
j=0
for i in range(n):
for j in range(0,n-j-1):
if L[j]<L[j+1]:
L[j], L[j+1] = L[j+1], L[j]
for count in range(n):
if (count<3):
print(L[count])
else:
break
n=len(L)
j=0
for i in range(n):
for j in range(0,n-j-1):
if L[j]<L[j+1]:
L[j], L[j+1] = L[j+1], L[j]
for count in range(n):
if (count<3):
print(L[count])
else:
break
2020-12-24
template = 'Life is {a},you need {b}。'
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