generate functionTue, 07 Mar 2023

a fractional number n is entered from the keyboard. Output ten numbers whose sum is equal to n. The numbers range from 0.001213245678 to n. The numbers are positive. The first two digits after the decimal point in the number can be equal to 0. The remaining digits in the number go without repetition. The number must have twelve significant decimal places.

def digits(n): a = '' while len(a) < 12: b = str(n)[:3] if int(b) > 999: b = str(n)[:2] if int(b) > 99: b = str(n)[0] if int(b) > 9: b = str(b)[:1] if b not in a: a += b else: b = str(n)[5] if b not in a: a += b n += 0.000000000001 return a digits(0.001213245678)

Questions about programming?Chat with your personal AI assistant