lundi 19 août 2019

Comparing function argument with float key

ycr = {'0.08': 2.40/100,
       '0.16': 2.40/100,
       '0.25': 2.42/100,
       '0.5' : 2.51/100,
       '1': 2.60/100,
       '2': 2.50/100,
       '3': 2.47/100,
       '5' : 2.49/100,
       '7' : 2.56/100,
       '10': 2.66/100,
       '20': 2.83/100,
       '30': 2.97/100} 

x = 1.5
y = ycr


def interpolation_calculator(x,y):
    lista = []
    listb = []
    {float(key):ycr[key] for key in ycr}
    for i in ycr:
        if x < key:
           lista.append()
        elif x > key:
            listb.append()
        else : 
            print(do nothing)
        lista.sort()
        listb.sort()

Hi im trying to compare the X argument with the key so that i can get the corresponding value and append it into the respective list. i changed the key to a float so that it can be compared to the argument of 1.5 but i do not know how to do the for loop for this. If x < (?). DO i need to find the index of the pair or is there a easier way? Any help would be appreciated !!

Aucun commentaire:

Enregistrer un commentaire