Challenge
Summary function
…{'count': 0, 'min': None, 'max': None, 'mean': None} Check if not readings: first and return early.
Showing 91–100 of 100
Challenge
…{'count': 0, 'min': None, 'max': None, 'mean': None} Check if not readings: first and return early.
Quiz
…, and where UnboundLocalError comes from Blocks such as if and for , which have no scope of their own, and list comprehensions, which do Nested functions, the nonlocal keyword and the order in which…
Quiz
…Leaving a function early with return : inside an if , a loop or nested loops Using a returned value straight away, and returning one of two values with a conditional expression How it works 15…
Challenge
…Site: 18.4447° N, 77.4508° E Choose each letter with an if : 0 and above is N or E, below 0 is S or W. abs() gives a number without its sign. Curiosity's landing site, (-4.5895, 137.4417), would be…
Challenge
…gives the index of the first character of the match, or -1 if there's no match at all. The message The flight director wants just the message that comes after ERROR and the space after it. Add a line…
Challenge
…. Every copy is a place someone would have to change if the report were rerun for the Moon. Modify. Add two constants above the prints, written in capitals so everyone knows they don't change, for…
Challenge
…alarms go off when an ERROR line appears. That only works if every line has exactly the same shape: [T+00:12:05] INFO Engines nominal The time since launch in square brackets, the level, two spaces…
Article Python Fundamentals
…Total power production How many computers can run if each needs 100 watts Remaining watts after powering the computers Use modulus (%) to find the remaining watts. Photo by Kier in Sight Archives on…
Article Python Fundamentals
…del from nonlocal while and elif global not with as else if or yield break except import pass Example of valid variable names in space context: orbital_velocity = 7.8 # kilometers per second…
Article Mini projects
…Making It More Interesting What if we want to add some mission parameters? Let's create a more advanced function: def generate_mission(): planet, details = select_random_destination() mission_duration…