mercredi 25 avril 2018

Python multiple if else function and return

Is this possible on python ?

ef NearSourceFactor(seismic_source_distance,seismic_source_select): 
Na = 0 
if (seismic_source_distance <= 2) and (seismic_source_select == "A"):
    Na == 1.5
elif (seismic_source_distance <= 5) and (seismic_source_select == "A"):
    return Na == 1.2
elif (seismic_source_distance > 10) and (seismic_source_select == "A"):
    return Na == 1.0
elif (seismic_source_distance <= 2) and (seismic_source_select == "B"):
    return Na == 1.3
elif (seismic_source_distance <= 5) and (seismic_source_select == "B"):
    return Na == 1.0
elif (seismic_source_distance > 10) and (seismic_source_select == "B"):
    return Na == 1.0
elif (seismic_source_distance <= 2) and (seismic_source_select == "C"):
    return Na == 1.0
elif (seismic_source_distance <= 5) and (seismic_source_select == "C"):
    return Na == 1.0
elif (seismic_source_distance > 10) and (seismic_bldg_geometry == "C"):
    return Na == 1.0
 Na = NearSourceFactor(seismic_source_distance,seismic_source_select) 

seismic_source is 10 and seismic_source_select = B but unfortunately the answer is = "None"

i'm expecting the answer is 1.0

Thank you very much

Aucun commentaire:

Enregistrer un commentaire