generate functionMon, 06 Mar 2023

enter a floating point number n. Output ten numbers the total sum of which is equal to n. In the ten numbers displayed, the numbers do not go in a row. The output ten digits have exactly twelve digits after the decimal point. the numbers are positive.

import random def random_adder(n): x = 0 i = 0 while x < n: y = round(random.random(), 12) x += y i += 1 if i <= 10: print(y) random_adder(10)

Questions about programming?Chat with your personal AI assistant