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

Congratulations!

Congratulations, Mrs Carter's invoice is done, and you've reached the end of Programming with AI! Your program works out every line of the invoice from the month's walks, and your tests wait in tests(), ready to check it whenever you change something. The AI wrote much of the code, and you decided and checked every step.

One last thing. Mrs Carter would like to know how long her dog was out altogether, and the invoice should still look right in a month of fewer than 10 walks, when there's no discount.

What you've learned. Look at where each part of the course came in:

  • The AI sees only what you send. Each question about your program went with script.py attached, and the one about the wrong total with what the program printed, too.
  • Saying what the code should do. Two lines as an example settled how print_weeks() prints, and that each walk is priced on its own.
  • Running it before you trust it. Answers said what the program would print, and some of it was wrong. The console was right every time.
  • Finding mistakes with AI. The program, what it printed and what you expected got you the line to change, not a new program.
  • Small steps. A plan without code first, then one step at a time, each run before the next.
  • Tests first. Three tests said exactly what discount() returns before it existed, and a test you worked out by hand caught a total that looked right.
  • When it makes things up. Answers can be sure and wrong at once: one of them promised Week 3 (105 min): 30, and the program printed 24.
  • A tutor, not a homework machine. You asked for feedback without a rewrite, then made the change yourself, with your names and with what you know.
  • Coding agents. An agent could have written all of this into script.py for you. You'd still read each change and run the tests before trusting it.

Your own programs. The same way works for whatever you write next: describe what you need with an example, write the tests first, build one step at a time, run every answer, and keep the program yours. And when the AI helped with schoolwork, say so.

What's next. The answers in this course kept using things you haven't learned yet, or have learned only from an answer: sum() with a for inside its parentheses, math.ceil(), dictionaries. The rest of the Python course, from Dictionaries on, teaches them: dictionaries, text, sorting, comprehensions, exceptions, modules and classes. The more of it you know, the more of an answer you can read, and the less you need to ask. And if you'd like to build websites and apps, the Web Development path takes you from your first page to an app of your own, in the right order.

Instructions

  1. 1

    Under the line that prints Walks, print the month's time in hours and minutes: Time: 6 h 45 min. For it, you need all the month's minutes together. A function month_minutes(weeks) can add them up, much as count_walks() counts the walks. Then // 60 gives the hours, and % 60 the minutes that are left.

  2. 2

    Print the line with the discount only when there is a discount: put it in an if that checks whether discount(count, total) is more than 0. To see it work, take the walk of 25 minutes out of the last week and run the program: the invoice has no Discount line, and it ends with To pay: 90. Then put the walk back.

Back

6/6

  1. 1. The Invoice
  2. 2. Tests First
  3. 3. One Step at a Time
  4. 4. What the Test Shows
  5. 5. Feedback on Your Program
  6. 6. Congratulations!

Start programming for free

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

Or sign up with: