Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

A function that returns smallest decimal number based on the input parameter

I want to have a function (def smallest_value(number):) that returns numbers like this:

    smallest_value(0) >> 1
    smallest_value(1) >> 0.1
    smallest_value(2) >> 0.01
    smallest_value(3) >> 0.001
    smallest_value(4) >> 0.0001

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try this one:

def smallest_value(number: int) -> float:
    return 10**(-number)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading