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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply