Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

The Smallest Change

Asked to fix a program, the AI usually sends a whole new one. It may work, and still not be what you need: to see what was wrong, you have to compare it with yours line by line, and it often changes more than the mistake, rewriting lines that were fine in a way you haven't learned.

The program in the editor prints Total: 42, and Mia's walks cost 6 + 12 + 6 + 12 = 36. Asked Fix it., with the program, what it printed and the right total, one answer sent the whole program back with this function in it:

def walk_price(minutes):
    half_hours = (minutes + 29) // 30  # round up to the next half hour
    return half_hours * 6

It gives the right total, and the answer explained: “Rounding up to the next half hour fixes both problems.” But the if is gone, (minutes + 29) // 30 is a trick you haven't learned, and nothing in the answer says that Mia's function was right except for one operator: // where % belongs. The same message gets a different answer each time. The others sent a whole program or a whole function too, and most of them replaced the function with something new, one with math.ceil() and max(), and a minimum price that Mia never asked for.

Ask for the smallest change instead: which line to change, how and why. You keep your program and your names, you learn what was wrong, and you can check the change yourself.

Instructions

  1. 1

    Run the program. Attach script.py and what it printed, say that the walks cost 6 + 12 + 6 + 12 = 36, and ask for the smallest change that fixes it: which line to change, and why. Say that you don't want the whole program again. Then send it.

  2. 2

    Change that line in your program, and only that line. Run it: it prints Walks: 4 and Total: 36.

  3. 3

    Mia walked Max for 75 minutes today. Add 75 at the end of the list and run the program. It prints Walks: 5 and Total: 54.

Back

6/7

  1. 1. The Whole Error
  2. 2. No Error, a Wrong Result
  3. 3. Quiz: Which Message Helps
  4. 4. The Fix Didn't Work
  5. 5. Quiz: Half a Fix
  6. 6. The Smallest Change
  7. 7. Summary
Next

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with: