Night 20: Weekly report
이미 Python 또는 의사 코드로 이날의 학습을 마쳤습니다. 두 언어 모두에서 완료한 것으로 인정됩니다. 원하면 다시 연습하세요.
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Tonight: weekly report
- Your pet counted the stars every night this week. Tonight you write a report.
- You will learn one thing: quick tools for lists of numbers:
sum,min,max.
Words for tonight
| Word | Meaning |
|---|---|
| total | all the numbers added together |
| largest / smallest | the biggest / the least |
| average | the total divided by how many numbers there are |
English
Three quick tools
stars = [3, 9, 2, 8, 5, 1, 7]
print("Total:", sum(stars))
print("Most:", max(stars))
print("Fewest:", min(stars))
| Tool | Gives |
|---|---|
sum(stars) |
35 |
max(stars) |
9 |
min(stars) |
1 |
len(stars) |
7 |

English
The average
- Average = total ÷ how many.
stars = [3, 9, 2, 8, 5, 1, 7]
average = sum(stars) / len(stars)
print("Average:", average)
English
When you need the position
maxgives the biggest value. But which night was it?- Use a loop and remember the position of the best so far.
stars = [3, 9, 2, 8, 5, 1, 7]
best = 0
for i in range(len(stars)):
if stars[i] > stars[best]:
best = i
print("Best night:", best + 1)
- Week 3 is almost done. Now write your pet's report!
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Your pet counted stars for 7 nights: stars = [3, 9, 2, 8, 5, 1, 7]. Print the total with sum. The output is 35.
출력을 보려면 '실행'을 클릭하세요.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Print the most stars on one night, then the fewest, on two lines. The output is 9 and then 1.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Work out the average: the total divided by the number of nights. Use sum 및 len. Print it: 5.0.
출력을 보려면 '실행'을 클릭하세요.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
Which night was best? Use a loop to find the position of the biggest number. Print Best night: 2 (night 1 is position 0).
출력을 보려면 '실행'을 클릭하세요.