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

No Error, a Wrong Result

A program that ends with an error at least tells you something is wrong. A program that runs and prints a wrong result tells you nothing: you find out when you check the result. And then there's no error to send.

What the AI needs instead is what you know and it doesn't. It can't run the program, so it knows what the program prints only if it works it out, and it can't know what you wanted it to print. A program that does exactly the wrong thing looks just like one that does the right thing. So say both, with the numbers: what it prints, and what you expected instead. The AI then looks for the line that makes the difference, instead of guessing what you meant.

Mia took the program that finds her longest walk and changed it to find the shortest: longest became shortest, and > became <. It runs without an error. Her shortest walk this week was 20 minutes.

Instructions

  1. 1

    Run the program. Attach script.py, and write what the program prints and what you expected instead. Ask which line makes the difference, and why. Then send it.

  2. 2

    Make the change the answer suggests, keep the list of walks as it is, and run the program. It prints Walks: 4 and Shortest: 20.

Back

2/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: