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

Explain It, Don't Fix It

A hint helps you find a mistake. To stop making it, you need to know why it's a mistake. Most mistakes are of a kind that comes back, such as a loop that ends too early or a variable set to 0 in the wrong place, and once you understand the kind, you'll spot it in the next program by yourself. So when your program goes wrong, ask what the mistake is and why, and say that you'll fix it yourself.

You won't always have a tutor's instructions: in a new chat, in another app, on a computer at school. Then say it in the message. If you don't, the answer explains the mistake in a sentence or two and then fixes it, and the fixed program is what you'd read. Asked My program ends with this error. What's wrong with it?, with the program in the editor and what it printed attached, one answer began:

The error happens because walk_price doesn't return anything. It only prints the price, so it returns None by default. In the loop, total = total + walk_price(minutes) adds total to None, which Python doesn't allow.

A few lines later came Fix: and the whole program, corrected. Every answer we got had the corrected program in it.

The program in the editor works out the price of each of Mia's walks with walk_price(), £6 for every started half hour, and adds the prices up. It ends with an error. To send what it printed with the error, click Attach to message on the console after the run: it goes with your message as output.txt.

Instructions

  1. 1

    Run the program. Then attach script.py, and with Attach to message on the console, what it printed. Ask what the error means and why your program gets it, and say that you don't want it fixed: you'll fix it yourself. Then send it.

  2. 2

    Fix the program yourself, keeping the list of walks as it is, and run it. It prints Total: 24.

Back

2/7

  1. 1. Hints First
  2. 2. Explain It, Don't Fix It
  3. 3. Quiz: The Same Mistake
  4. 4. Feedback, Not a Rewrite
  5. 5. Let It Quiz You
  6. 6. Quiz: Who Writes It?
  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: