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

Question:

I am trying to build a function called smallest_value that takes an integer as an input and returns a float. The float should be equal to 10 raised to the power of -number. For example, if number is 2, the function should return 0.01.

I am struggling with writing the function and could use some help. Can anyone guide me on how to do this in Python? Thank you!

    smallest_value(0) >> 1
    smallest_value(1) >> 0.1
    smallest_value(2) >> 0.01
    smallest_value(3) >> 0.001
    smallest_value(4) >> 0.0001
Asked By: Nima

||

Answers:

Try this one:

def smallest_value(number: int) -> float:
    return 10**(-number)
Answered By: Roniel López
10**(-k)

Where k is the your number.

Answered By: stukituk
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.