Challenge
Log formatter function
…The output must stay exactly the same: [T+00:12:05] INFO Engines nominal Define the function at the top: def format_log(t, level, msg): , with return f"..." inside, using its own parameter names. Then…
Showing 11–20 of 21
Challenge
…The output must stay exactly the same: [T+00:12:05] INFO Engines nominal Define the function at the top: def format_log(t, level, msg): , with return f"..." inside, using its own parameter names. Then…
Article Mini projects
…# Get planet details planet_info = planets[destination] return destination, planet_info # Let's try our space lottery! planet, details = select_random_destination() Making It More Interesting What if…
Challenge
…key=value , in the order they were passed: [T+00:12:05] INFO Engines nominal [T+00:14:47] ERROR Fuel valve 2 not responding valve=2 pressure_kpa=310 Add **fields after msg . Inside, fields is a dict…
Example
Simple way to check installed Python version on your system. First step for every programmer.
Challenge
Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.
Example
Functions can return complex data structures like dictionaries or lists.
Article Python Fundamentals
…print() function helps you display this basic yet crucial information on your computer's console. Your first message to Mission Control Let's start with the basics. Here's how to send your first…
Article Mini projects
…Before we start writing code, we need to determine what information we'll need from the program user: Which temperature they want to convert: Celsius or Fahrenheit to Kelvin. What is the value of this…
Article Python Fundamentals
…its uses, but most of the time you want to hand it some information and let it work with that. def greet_astronaut(name): print(f"Welcome aboard, {name}.") greet_astronaut("Ada")…
Article Python Fundamentals
…begginers ! What are variables really? Variables store information you want to use later. Here's what you need to know: # Numbers speed = 28000 # Whole number temperature = -45.2 # Decimal number #…