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

Summary

In this lesson, you learned that:

  • A vague request gets guesses: prices nobody told the AI, input(), a program of its own. Say what goes in, what comes out and the name your program calls.
  • Words that are clear to you can be read another way. Examples with numbers settle it, picked where the rule changes, such as 30 and 31 minutes, and you check the function with them.
  • The AI writes for anyone, on a computer it imagines. Say what you know and where the program runs: here, there's no input(), no files and no installed libraries.
  • Say what form you need: only the function to paste, or a comment on each line to read it later.
  • Run what you paste. A function can fit your examples and still be wrong for other numbers, so the exercises here try other minutes too.

Practice it all at once. Mia is thinking of another discount, for a whole week: £5 off a week of five walks or more. The program in the editor has her walks and walk_price(), and its last line calls week_price(walks), which you'll ask for.

Next comes Run It Before You Trust It: code that runs can still be wrong, and how to find out.

Instructions

  1. 1

    Attach script.py and ask for week_price(walks) as this lesson taught: what goes in and what comes out; the discount, with examples (walks of 30, 45, 20 and 60 minutes cost £36, and with one more of 75 minutes, £49); what you know and where the program runs; and only the function. Then send it.

  2. 2

    Paste the function in place of the comment and run the program. Keep the line with the walks: the program prints Total: 49.

Back

6/6

  1. 1. What Goes In, What Comes Out
  2. 2. Examples Settle What Words Don't
  3. 3. What You Know, Where It Runs
  4. 4. The Form You Need
  5. 5. Quiz: Which Request
  6. 6. Summary
Next

Start programming for free

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

Or sign up with: