mercredi 24 janvier 2018

Printing the function which contains if statements, Python

I am try to print my function in Python on Visual Studio, it has a number of "if" statements within it:

def correction(Diff):
    if 1 <= Diff <20 : 
        print "correction 1" # is correction necessary?
    elif 20 <= Diff < 49:
        print "correction 2" # Slight turn to right
    elif 50 <= Diff < 74:
        print "correction 3" # turn to right
    elif 75 <= Diff < 100:
        print "correction 4" # 'sharp' turn to right
    elif 100 <= Diff:
        print "correction 9" # STOP
    elif -20 <= Diff < 0:
        print "correction 5" # is correction necessary?
    elif -50 <= Diff < -20:
        print "correction 6" # Slight turn to left
    elif -75 <= Diff < -50:
        print "correction 7" # turn to left
    elif -100 < Diff < -75:
        print "correction 8" # 'sharp' turn to left
    elif Diff9 <= -100:
        print "correction 9" # STOP
    else:
        print "carry on"
return correction

print (correction)

Diff is fully defined before the function. However when i run the code, I get this message appear in place of the print: "function correction at 0x073EECB0"

I would the function to run and print the correct statement. The hope is to transfer this code for use on videos, therefore suggestions and help using which minimise processing power would be great.

Aucun commentaire:

Enregistrer un commentaire