L = [75, 92, 59, 68, 99]
sum = 0.0
ab = len(L)
for i in L:
sum = sum + i
print(sum/ab)
sum = 0.0
ab = len(L)
for i in L:
sum = sum + i
print(sum/ab)
2025-03-10
age = 4
if age >= 18:
print("adult")
elif age >= 6:
print("teenager")
elif age >=3:
print("kid")
else:
print("baby")
if age >= 18:
print("adult")
elif age >= 6:
print("teenager")
elif age >=3:
print("kid")
else:
print("baby")
2025-03-10
result = 0
num = 0
while True:
if num <= 1000:
result += num
num += 2
else:
break
print(result)
num = 0
while True:
if num <= 1000:
result += num
num += 2
else:
break
print(result)
2025-03-03
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for k,v in d.items():
for v in d[k]:
print(k,v)
for k,v in d.items():
for v in d[k]:
print(k,v)
2025-03-03
print('方式1')
tp = 'Life is {},you need {}'
print (tp.format('short','python'))
print('方式2')
tp1= 'Life is {0},you need {1}'
result1=tp1.format('short','python')
print(result1)
tp = 'Life is {},you need {}'
print (tp.format('short','python'))
print('方式2')
tp1= 'Life is {0},you need {1}'
result1=tp1.format('short','python')
print(result1)
2025-02-28
a = r'''
"to be,or not to be":that is the question
whether it's nobler in hte mind to suffer!'''
print (a)
"to be,or not to be":that is the question
whether it's nobler in hte mind to suffer!'''
print (a)
2025-02-28
L1 = [1, 2, 3]
L2 = [5, 3, 2]
L3 = [7, 3, 2]
def s(L):
A = L[0] * L[1] + L[1] * L[2]+ L[0] * L[2]
return A
print(s(L1), s(L2), s(L3))
L2 = [5, 3, 2]
L3 = [7, 3, 2]
def s(L):
A = L[0] * L[1] + L[1] * L[2]+ L[0] * L[2]
return A
print(s(L1), s(L2), s(L3))
2025-02-28
a = 'python'
print('hello,', a or 'world')
#a為非空字符串,所以為True,或運算,a為True則返回a
b = ''
print('hello,', b or 'world')
#b為空字符串,所以為False,b為False,或運算,有一個為True則結果為True,所以返回后面的word
print('hello,', a or 'world')
#a為非空字符串,所以為True,或運算,a為True則返回a
b = ''
print('hello,', b or 'world')
#b為空字符串,所以為False,b為False,或運算,有一個為True則結果為True,所以返回后面的word
2025-02-27
3.1415926 浮點數
'Learn Python in imooc.' 字符串
100 整數
0b1101 二進制整數
'Learn Python in imooc.' 字符串
100 整數
0b1101 二進制整數
2025-02-27