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

The Busiest Day

The last piece is the busiest day, the day with the most minutes of walks. Mia asked for it in a new chat and put the function from the answer she got under longest_walk(), with a line at the end of the program that prints it. busiest_day() adds up each day's minutes in a dictionary, as minutes_per_dog() does for each dog, so you can read that part now. Then it picks the busiest day with a method you haven't seen: most_common().

Nothing in the code tells you whether that method exists: a made-up name looks just like a real one. That's why Mia gave the piece a test as soon as she pasted it, as you did with the others: print(busiest_day(test_week) == "Tue"), under the other tests. If the method is made up, that test is where the program stops.

If it's made up, do what you did in When It Makes Things Up: send the program with what it printed, and ask for a version with only what you know, so that every name in it is one you can check.

Once it runs, the report is finished: four pieces, each with its own test. Three count with a dictionary, which you learned from an answer, and one you wrote yourself. Next comes A Tutor, Not a Homework Machine: how to have the assistant help you learn instead of doing the work for you.

Instructions

  1. 1

    Run the program. Attach script.py and what it printed (Attach to message on the console), ask whether a dictionary really has most_common(), and ask for a busiest_day() with only what you know: lists, loops, if, functions and the dictionaries of minutes_per_dog(). Then send it.

  2. 2

    Paste the new busiest_day() in place of the old one and run the program. The tests print True, Mia's new one too, and the report ends with Busiest day: Wed.

Back

4/4

  1. 1. Minutes per Dog
  2. 2. Earnings per Dog
  3. 3. The Longest Walk
  4. 4. The Busiest Day
Next

Start programming for free

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

Or sign up with: