Page 1 of 1

How to Think Like a Computer Scientist: Learning with Python 3 Chapter 7 Exercises Question 14 14. What will num_digits(

Posted: Sun Jul 03, 2022 11:22 am
by answerhappygod
How to Think Like a Computer Scientist: Learning with Python3
Chapter 7 Exercises
Question 14
14. What will num_digits(0) return? Modify it to return 1 forthis case. Why does a call to num_digits(-24) result in an infiniteloop? (hint: -1//10 evaluates to -1) Modify num_digits so that itworks correctly with any integer value.
Add these tests:
test(num_digits(0) == 1)
test(num_digits(-12345) == 5)