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

Leave the Rest as It Is

A program you've built and checked piece by piece is worth keeping as it is. When you ask for a change, an assistant may give you more than you asked for: a new function, a tidier version of one you wrote, a report with lines you didn't want. Pasted in, it changes code you had already checked, and you have to check all of it again.

Mia has made up her mind about a discount: she now gives £5 off a week of five walks or more. Asked just that, with the program attached, one answer added a function of its own for the discount and rewrote print_report(), which then printed two new lines:

Walks: 5
Time: 190 min
Subtotal: 48
Discount: 5
Total: 43

The total is right, but it isn't Mia's report anymore, and print_report() isn't the one you checked. Other answers to the same message rewrote print_report() too. So say where the change goes and what stays as it is, by name. Here, the discount belongs in week_total(), and walk_price(), total_minutes() and print_report() stay. After pasting, check that they did.

Instructions

  1. 1

    Attach script.py and say where the change goes: only week_total() changes, so that it takes 5 off the total of a week with five walks or more. Say that the rest stays as it is: walk_price(), total_minutes() and print_report(). Then send it.

  2. 2

    Paste the new week_total() in place of the old one. If the answer has the whole program, compare it with yours before you paste it: print_report() has to print week_total(walks) after Total:, as it did.

  3. 3

    Run the program. It prints Total: 43, five less than before. Don't take the answer's word for the total: one answer said it “goes from 36 to 31”, with the right code and a wrong sum, and other answers got the sum wrong too.

Back

4/7

  1. 1. A Plan Before Code
  2. 2. One Piece at a Time
  3. 3. Quiz: The Piece Just Added
  4. 4. Leave the Rest as It Is
  5. 5. A New Chat
  6. 6. Quiz: A Long Chat
  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: