vendredi 15 avril 2016

Calculate each updated value and its corresponding random and then graph them

import random
import matplotlib.pyplot as plt

a1 = ['','','?','']
a2 = [10,25,43.34,90]

i = 0
i_array = []
while i < 10:
    i_array.append(i)
    i = i + 1
    r = random.random()
    if '?' in a1:
        a3 = a2 * r  #Here I am trying to pull 43.34 and multiply it by the 10 random values "r"
                     #generated by the code. Then line-graph each random value on x-axis and their
                     #corresponding changed value on y-axis.

plt.line(r,a3)

The question mark I have in a1 could be in any place out of those four places. So, the value corresponding to it in a2 needs to be changed.




Aucun commentaire:

Enregistrer un commentaire