So far the hardest part has been getting used to python which I don't think I've done anything real in ever.
I'm a python freak
also a javascript freak
I love them both. sometimes I use one or another. I don't know what determines whether I choose to use one or the other for a given task, aside from perhaps library availability
at work I have this stupid, awful task that involves me making up random numbers off the top of my head within a certain range
I got tired of making them up myself (previously my least favorite part of doing it), so I made a python script to do it for me
import random
parts = [
["86697-C2000", 302.0, 15, 3],
["86697-C2200", 292.0, 6, 3],
["86697-C2300", 288.0, 15, 3],
["84716-4Z000", 180.0, 15, 5],
["86717-4Z000", 185.0, 15, 5],
["55163-F2000", 705.6, 15, 3]
]
output = ""
for part, avg, rng, samples in parts:
output += part + ": "
sample_list = []
for i in range(samples):
sample_list.append('{:.1f}'.format(random.uniform(avg - rng, avg + rng)))
output += ', '.join(sample_list) + '\n'
print(output)output generally looks something like this:
86697-C2000: 287.9, 295.0, 309.5
86697-C2200: 293.6, 286.2, 286.2
86697-C2300: 293.2, 302.4, 283.9
84716-4Z000: 182.1, 171.4, 183.6, 194.3, 176.1
86717-4Z000: 184.3, 190.8, 190.6, 174.8, 199.3
55163-F2000: 700.8, 710.0, 693.8in this particular case it's easy to explain that I chose python because its random module is much more convenient than javascript's
Math.random()but sometimes the reasons are much more abstract