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: try and except

What does this program print?

1for text in ["4", "0", "two"]:
2    try:
3        number = int(text)
4        print("Number:", number)
5        print("Result:", 100 // number)
6    except ValueError:
7        print("Not a number:", text)
8    except ZeroDivisionError:
9        print("Can't divide by zero")
Back

4/10

  1. 1. Reading a Traceback
  2. 2. Catching an Error
  3. 3. Which Error?
  4. 4. Quiz: try and except
  5. 5. The Message of an Error
  6. 6. else and finally
  7. 7. Quiz: else and finally
  8. 8. Raising an Error
  9. 9. Catching Your Own Errors
  10. 10. Summary
Next

Try it yourself

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