L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for i in L:
a = 0
b = 0
c = 0
for j in i:
a = i[0]
b = i[1]
c = i[2]
s =2*((a*b) + (a*c) + (b*c))
print('area:' + str(s))
for i in L:
a = 0
b = 0
c = 0
for j in i:
a = i[0]
b = i[1]
c = i[2]
s =2*((a*b) + (a*c) + (b*c))
print('area:' + str(s))
2021-07-03
# Enter a code
#coding = utf-8
a = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
b = [ 89, 72, 88, 79, 99]
c = []
while True:
if len(b) != 0:
print('--------------------------')
biggest = max(b)
print('maxb:' + str(biggest))
#coding = utf-8
a = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
b = [ 89, 72, 88, 79, 99]
c = []
while True:
if len(b) != 0:
print('--------------------------')
biggest = max(b)
print('maxb:' + str(biggest))
2021-07-03
L = [95.5,85,59,66,72]
L.sort(reverse=False)
print(L[-3:])
L.sort(reverse=False)
print(L[-3:])
2021-07-01
T = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(T.count(100))
print(T.count(100))
2021-06-29
# Enter a code
n=0
s=0
while True:
if n>1000:
break
s=s+n
n=n+2
print(s)
n=0
s=0
while True:
if n>1000:
break
s=s+n
n=n+2
print(s)
2021-06-29
#coding=utf-8
age=18
if age>=18:
print('成年')
elif age>=6 and age<=17:
print('青少年')
elif age>=3 and age<6:
print('小孩')
else:
print('嬰兒')
age=18
if age>=18:
print('成年')
elif age>=6 and age<=17:
print('青少年')
elif age>=3 and age<6:
print('小孩')
else:
print('嬰兒')
2021-06-29
score = [95.5, 85, 59, 66,72]
sub_score = score[0:3]
print(sub_score)
sub_score = score[0:3]
print(sub_score)
2021-06-29
L = ['Alice', 66, 'Bob', True, 'False', 100]
count = 0
for goods in L :
if count %2 == 0:
print(goods)
count = count + 1
count = 0
for goods in L :
if count %2 == 0:
print(goods)
count = count + 1
2021-06-29
L = [75, 92, 59, 68, 99]
sum = 0
for ch in L:
sum = sum+ch
print(sum/5)
sum = 0
for ch in L:
sum = sum+ch
print(sum/5)
2021-06-28
# Enter a code
L = [75, 92, 59, 68, 99]
sum = 0
for c in L:
sum+=c
print(sum)
L = [75, 92, 59, 68, 99]
sum = 0
for c in L:
sum+=c
print(sum)
2021-06-28
可以試一下這個(gè),結(jié)果一樣,但意思是直接創(chuàng)建新的元素和數(shù)據(jù)。
d = dict()
d['Alice']=[50,61,60]
d['Bob'] = [80,61,66]
d['Candy'] = [88,75,90]
print(d)
d = dict()
d['Alice']=[50,61,60]
d['Bob'] = [80,61,66]
d['Candy'] = [88,75,90]
print(d)
2021-06-28
利用for更加簡單方便
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
c = ('Alice', 'Bob', 'Candy', 'Mimi', 'David')
for a in c:
print(d.get(a))
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
c = ('Alice', 'Bob', 'Candy', 'Mimi', 'David')
for a in c:
print(d.get(a))
2021-06-28
# coding=utf-8
# 長方形的長為3.14厘米,寬為1.57厘米,求長方形面積,保留兩位小數(shù)
a=3.14
b=1.57
A=round(a*b,2)
print('長方形的面積是'+str(A)+'平方厘米')
# 長方形的長為3.14厘米,寬為1.57厘米,求長方形面積,保留兩位小數(shù)
a=3.14
b=1.57
A=round(a*b,2)
print('長方形的面積是'+str(A)+'平方厘米')
2021-06-27