Challenge
Counter
…per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with most_common().
8 results
Challenge
…per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with most_common().
Challenge
Turn the launch-day mission log into answers: parse each line into a dict, count the entries per level and per hour, find the first ERROR, then rank the subsystems by how many warnings they raised.
Example
Lists store multiple elements in a specific order. Basics of working with lists.
Quiz
…types: numbers, text, True and False , None , and the four collections you will use all the time. What the quiz covers Numbers: int and float , mixing them and why 0.1 + 0.2 is not exactly 0.3 Text (…
Article Python Fundamentals
…engines_active = False Complex Data Types Lists Ordered collections of items, great for storing sequences of data: planet_names = ["Mercury", "Venus", "Earth", "Mars"] temperatures = [167, 464, 15…
Example
For loop iterates through sequence elements. Basic iteration over lists.
Article Mini projects
…need the secure approach shown later. import time from collections import deque class MonotonicMedicationDispenser: """Uses monotonic time - can't be tricked by system clock changes Note: This only…
Article Mini projects
…in m/s². What's a Dictionary? In Python, a dictionary is a collection of key-value pairs. It's like a real-world dictionary where you have a word (the key) and its definition (the value). In our…