vendredi 24 mars 2017

Python 2.7 run combinations on if, elif, elif statements

I currently have code that computes a combination of distances between two points for my tuple. I'm trying to take these distances, which I've sorted using the code below:

 if d > 1.4 and d < 1.6:
       print("The bond is a single bond")
    elif d >= 1.21 and d < 1.4:
       print("The bond is a double bond")
    elif d >= 1 and d <= 1.2:
       print("The bond is a triple bond")
    else:
        print("No bond exists")

to get

Computing distance between carbon_11 and carbon_13
The bond is a single bond

I'd like to be able do another combination with these distances but only allow carbon_ to have max four bonds (four "single", or two "single" and one "double", or one "single" and one "triple"), but four bonds are not required. I'm very new to Python so I am not sure how to take the distances from my if, elif, elif statements and run another combination such that the distances still coincide to single, double, and triple bonds. Any help is greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire