Python Foundations·Practice drills 8

Drill 12: Key term — Functions and collections

Identify the key term in the example and define it.

Beginner 5 min read Lesson 199 of 480 Challenge included
What you will be able to do
  • Identify the key term in the example and define it.

Practice task

Identify the key term in the example and define it.

collections.pyPython
def average(values):
    if not values:
        return 0
    return sum(values) / len(values)

scores = {"html": 88, "css": 92, "js": 79}

for skill, score in scores.items():
    print(f"{skill.upper()}: {score}")

passed = [skill for skill, score in scores.items() if score >= 80]
print(f"Passed: {passed}")
print(f"Average: {average(list(scores.values())):.1f}")
Your turn

Write your answer

Easy

Identify the key term in the example and define it.

TEXT · starter
Your answer…
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 199 of 480 · 0% of course