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: At Least 30 Minutes

Reading code before you run it is a check too. Say what you think it prints, then run it: if the two differ, the code or your reading is wrong, and either is worth knowing. Someone asked an AI for a function that counts the walks of at least 30 minutes, and this is the answer they got. Read it without running it. What does it print?

1def long_walks(walks):
2    count = 0
3    for minutes in walks:
4        if minutes > 30:
5            count += 1
6    return count
7
8print("Walks:", long_walks([30, 45, 20, 60]))
9
Back

2/6

  1. 1. It Runs, and It's Wrong
  2. 2. Quiz: At Least 30 Minutes
  3. 3. The Cases Nobody Asked About
  4. 4. A Result That Looks Right
  5. 5. Quiz: The Limit
  6. 6. Summary
Next

Try it yourself

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