Skip to content
Omni Academy
Search courses and lessons
Search
Courses
Backend Development
9
Databases
1
Frontend Development
5
Data Science
5
All courses →
Playground
HTML & CSS
JavaScript
TypeScript
Python
PHP
Ruby
Light
Dark
Auto
Sign in
Get started
All
Backend Development
Databases
Frontend Development
Data Science
Playground
Blog
HTML
JS
TS
PY
PHP
RB
← Courses
📄
Python basics
Run as I type
Reset
▶
Run
Ctrl
↵
PY
Python source code
# Real CPython, compiled to WebAssembly. It runs in this tab, not on a # server, so nothing you type here leaves your browser. from dataclasses import dataclass from collections import Counter @dataclass class Learner: name: str score: int level: str learners = [ Learner("Aisha", 92, "advanced"), Learner("Kenji", 78, "intermediate"), Learner("Lena", 85, "expert"), ] # A comprehension with a condition reads as the sentence it is: # "the names of the learners who scored at least 80". passing = [l.name for l in learners if l.score >= 80] print("Passing:", passing) average = sum(l.score for l in learners) / len(learners) print(f"Average: {average:.1f}") # Counting without writing a loop that counts. print(Counter(l.level for l in learners))
Input
one line per
input()
call
Output
Rendered by your browser