L = [75, 92, 59, 68, 99]
sum =0
for i in L:
sum=i+sum
avg=sum/5
print(avg)
sum =0
for i in L:
sum=i+sum
avg=sum/5
print(avg)
2021-04-14
age = 5
if age>=18:
print('adult')
elif age<18 and age>=6:
print('teenager')
elif age<6 and age>=3:
print('kid')
else:
print('baby')
if age>=18:
print('adult')
elif age<18 and age>=6:
print('teenager')
elif age<6 and age>=3:
print('kid')
else:
print('baby')
2021-04-14
# Enter a code
age=12
if age>=18:
print("adult")
else:
print('teenager')
age=12
if age>=18:
print("adult")
else:
print('teenager')
2021-04-14
# Enter a code
age = 19
if age>=18:
print("adult:{}".format(age))
else:
print('weichengnian ')
age = 19
if age>=18:
print("adult:{}".format(age))
else:
print('weichengnian ')
2021-04-14
lis='Life {i}, you {n}'
lo1='is short'
lo2='need Python'
lls=lis.format(i=lo1,n=lo2)
print(lls)
lo1='is short'
lo2='need Python'
lls=lis.format(i=lo1,n=lo2)
print(lls)
2021-04-14
lis='Life {1}, you {0}'
lo=lis.format('need Python','is short')
print(lo)
lo=lis.format('need Python','is short')
print(lo)
2021-04-14
a='python'
print('hello,',a or 'world')
b=''
print('hello,',b or 'world')
# b为False,b or 'world'输出‘world’
print('hello,',a or 'world')
b=''
print('hello,',b or 'world')
# b为False,b or 'world'输出‘world’
2021-04-13
longs=3.14
wide=1.57
area=longs*wide
result=round(area,2)
print('长方形面积是:%s',result)
wide=1.57
area=longs*wide
result=round(area,2)
print('长方形面积是:%s',result)
2021-04-13
# Enter a code
a='h'
a1='e'
a2='ll'
a3='o'
b='Wo'
b1='rld'
# print(a+a1+a2+a3,b+b1)
c=(a+a1+a2+a3,b+b1)
print(c)
a='h'
a1='e'
a2='ll'
a3='o'
b='Wo'
b1='rld'
# print(a+a1+a2+a3,b+b1)
c=(a+a1+a2+a3,b+b1)
print(c)
2021-04-13
num=list()
x=1
while x<101:
num.append(x*x)
x=x+1
print(x)
print(sum(num))
x=1
while x<101:
num.append(x*x)
x=x+1
print(x)
print(sum(num))
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2)==False:
for x in s1:
if x in s2:
print(x)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2)==False:
for x in s1:
if x in s2:
print(x)
2021-04-12