Results for “variable”

Showing 11–20 of 53

  1. Challenge

    Shadowed fuel

    …assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a…

    Fix the code Medium 3 stages functions scope local variables global variables
  2. Challenge

    Safe mode

    …using or, then name the rule that fired with boolean variables and an if/elif chain.

    Write the code Medium 2 stages if elif or and
  3. Challenge

    Manifest line

    Unpack an (id, item, mass_kg) tuple into three named variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.

    Write the code Easy 2 stages tuples unpacking ValueError formatting
  4. Challenge

    Alert level

    …check the exact boundaries, then store the level in a variable for a status line.

    Write the code Easy 2 stages if elif else comparisons
  5. Article Python Fundamentals

    Nested Loops in Python

    …differently. Common Beginner Mistakes Mistake 1: Same Variable Names # BAD - inner loop overwrites x! for x in range(3): for x in range(3): # ← Overwrites outer x print(x) Python won't throw an error…

  6. Challenge

    Magic numbers

    Turn the bare 9.81 and 1000 in a weight report into named constants without changing the output, then write a Mars version with constants from the start.

    Fix the code Easy 3 stages constants refactoring variables clean code
  7. Article Mini projects

    Medical dispenser - Don’t trust the user

    …secret. Set MEDICATION_DISPENSER_SECRET environment variable for production.") return secret def _compute_hmac(self, message): """Compute HMAC-SHA256 of message using device secret""" return hmac.new(…