Random values in dictionary- python
Question: I have this `OrderedDict`:

    
    
    (
      [
        ('Joe', ['90', '0']),
        ('Alice', ['100', '0']),
        ('Eva', ['90', '5']),
        ('Clare', ['100', '10']),
        ('Bob', ['100', '5'])
      ]
    )
    

I have to create a function that takes the `OrderedDict` as an argument,
generates a random performance value using normal distribution and returns
these in an `OrderedDict` with names as keys.

The result should look like this:

    
    
    ([("Joe",91.362718),("Bob",100.0)...)
    


Answer: Do you mean you would like to have something like this:

    
    
    from collections import OrderedDict
    from scipy.stats import norm
    
    ordered_dict = OrderedDict(
      [
        ('Joe', ['90', '0']),
        ('Alice', ['100', '0']),
        ('Eva', ['90', '5']),
        ('Clare', ['100', '10']),
        ('Bob', ['100', '5'])
      ]
    )
    
    
    def draw_normal(input_dict):
        result = []
        for key in input_dict:
            loc, scale = input_dict[key]
            random_number = norm.rvs(loc=float(loc), scale=float(scale))
            result.append((key, random_number))
        return OrderedDict(result)
    
    print draw_normal(ordered_dict)
    

The output:

    
    
    OrderedDict([('Joe', 90.0), ('Alice', 100.0), ('Eva', 93.55249306218722), ('Clare', 105.280646961399), ('Bob', 104.29299844957707)])
    

