Results for “python def”

Showing 11–20 of 71

  1. Challenge

    Log formatter function

    …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…

    Fix the code Easy 2 stages functions def return refactoring
  2. Article Mini projects

    Calculating Escape Velocity in Python

    …let's break down our solution step by step: Step 1: Define Constants and Data First, let's specify what we know: import numpy as np # Gravitational constant - always the same in the universe G =…

  3. Article Mini projects

    Managing Astronaut Medical Data with Python

    …that class: import sqlite3 class CosmicHealthTracker: def __init__(self): #let's create database first self.create_database() def create_database(self): conn = sqlite3.connect('space_station.db')…

  4. Article Mini projects

    Base 6 Number System in Python

    …read in reverse order, give you the base-6 number. def decimal_to_base6(decimal_number): if decimal_number == 0: return "0" digits = [] # We'll collect remainders here number = decimal_number while…

  5. Article Mini projects

    Converting Temperatures in Python

    …handle them. Functions for converting temperatures Let's define 2 functions necessary for our calculations. These will be the celsius_to_kelvin and fahrenheit_to_kelvin functions: def…

  6. Challenge

    Config loader

    Load the downlink module's JSON settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even…

    Write the code Hard 3 stages project json configuration validation
  7. Article Mini projects

    Drawing Planetary Orbits in Python

    …planets and another to calculate their orbital paths: def create_planet(color, size): planet = turtle.Turtle() planet.shape("circle") planet.color(color) planet.shapesize(size) planet.penup() return…

  8. Article Mini projects

    Python Random Module

    …write a function that randomly selects our destination: def select_random_destination(): # Choose a random planet destination = random.choice(list(planets.keys())) # Get planet details planet_info =…