I am generating fake values amongst text as string.
I want to have this example output string:
2014_123.23 2015_456.40 2016_789.01 2017_1011.32
Where:
- prefix for each sub-string, separated by a space ' ', is are years 2014 to 2021.
- postfix for each sub-string is a 2-decimal place number, bigger than the previous.
Each postfix value has to be bigger than the previous sub-string's postfix value
So far, I have:
import numpy
import random
def year_tons(year_min, year_max):
v = [str(year) + '_' + str(round(random.uniform(100.00, 500.99), 2)) for year in range(year_min, year_max+1)]
v = " ".join(v)
print(v)
year_tons(2014, 2021)
Output:
2014_103.55 2015_468.8 2016_162.36 2017_363.14 2018_404.73 2019_424.0 2020_449.43 2021_147.34
Aucun commentaire:
Enregistrer un commentaire