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

Quiz: Half a Fix

At the start of this lesson, the answer said to give each walk's price a name of its own. Mia changed one line, and now her program ends with TypeError: unsupported operand type(s) for +: 'int' and 'function'. Click the line with the mistake.

1def walk_price(minutes):
2    half_hours = minutes // 30
3    if minutes % 30 > 0:
4        half_hours = half_hours + 1
5    return half_hours * 6
6
7def week_total(walks):
8    total = 0
9    for minutes in walks:
10        price = walk_price(minutes)
11        total = total + walk_price
12    return total
13
14walks = [30, 45, 20, 60]
15print("Total:", week_total(walks))
16
Back

5/7

  1. 1. The Whole Error
  2. 2. No Error, a Wrong Result
  3. 3. Quiz: Which Message Helps
  4. 4. The Fix Didn't Work
  5. 5. Quiz: Half a Fix
  6. 6. The Smallest Change
  7. 7. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.