Results for “len”

Showing 11–20 of 68

  1. Article Mini projects

    Medical dispenser - Don’t trust the user

    …self.dose_history if d.date() == current_time.date()] if len(today_doses) >= self.max_daily_doses: return "ACCESS DENIED: Daily limit reached" # Dispense the medication…

  2. Challenge

    Names with values

    …list of units and warn when the lists don't have the same length, since zip() quietly stops at the shortest.

    Write the code Easy 2 stages for loop zip lists unpacking
  3. Challenge

    Summary function

    …'mean': 419.5} Build the dict in the return line, with len() , min() , max() and sum() / len() . No data, and a rounded mean The second pass had no data, and min([]) stops with a ValueError . For an…

    Write the code Medium 2 stages functions return dictionaries min
  4. Challenge

    Shift rota

    …shifts: 0 Count the shifts in slot as you go: crew[slot % len(crew)] wraps round to the first person after the last. {name:<10} pads the names into columns. Days off, fairly Now some of the crew have…

    Write the code Hard 2 stages project scheduling lists tuples
  5. Challenge

    Unit mix-up

    …convert leg 2 before it's added. It must print: Trajectory length: 386,294 km Make: Landing in metres A lander's altitude comes from its radar in metres, but the backup sensor reports the descent rate…

    Fix the code Easy 3 stages units conversion constants debugging
  6. Challenge

    Any number of values

    …419.5 Inside the function, values is a tuple, so sum() and len() work on it. In the second call, average(*readings) passes the five readings as five separate arguments. An option after the values Add…

    Write the code Easy 2 stages functions *args unpacking keyword-only arguments
  7. Article Python Fundamentals

    Nested Loops in Python

    …loop: check systems in the rover for system_id in range(len(systems)): system_name = systems[system_id] # Randomly generate status (80% chance of OK) is_working = random.random() > 0.2 if is_working…

  8. Article Mini projects

    Managing Astronaut Medical Data with Python

    …astronaut = self.astronaut_var.get().split(' - ') if len(astronaut) != 2: messagebox.showerror("Error", "Please select an astronaut!") return astronaut_id = astronaut[0] date = self.date_entry.get()…