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

Ask About One Thing

When one line puzzles you, ask about that line, with a case: what does it give for 60 minutes? An explanation in general words can sound clear and still leave you unsure. Worked through with one number, it shows you every step, and you can check each of them.

Mia charges £6 for every started half hour: a walk of 30 minutes costs £6, and a walk of 31 minutes costs £12, because the second half hour has started. The function walk_price() in the editor works the price out, and the program prints the price of a 75-minute walk: two half hours and a started third, so 18. You know // and %, but it may not be clear why the function needs both, or what it does with a walk of exactly 60 minutes. Is that two half hours, or has a third one started?

Asking with a number also gives you something to check. What the AI works out for 60 minutes, the program prints when you call the function with 60.

Instructions

  1. 1

    Attach script.py and ask what walk_price() gives for a walk of exactly 60 minutes: two half hours or three. Ask for it to be worked out with the numbers, line by line. Then send it.

  2. 2

    Check the answer: below the line that prints the price of 75 minutes, add one that prints the price of 60 minutes in the same way, and run the program. It prints Price: 18 and Price: 12.

Back

4/7

  1. 1. It Sees Only What You Send
  2. 2. Explained at Your Level
  3. 3. Quiz: Numbered Walks
  4. 4. Ask About One Thing
  5. 5. Without That
  6. 6. Quiz: What It Knows About Your Program
  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: