Ask Your Question

Revision history [back]

To construct a function, you have to use def Python statement.

def cond(x, y):
    if x<y:
        print("Accepté")
    else:
        print("Rejeté")

To construct a function, you have to use def Python statement.

def cond(x, y):
    if x<y:
        print("Accepté")
    else:
        print("Rejeté")

EDIT given the comment, it seems that you do not want to only print the result, but you want the function to return the string. So, here it is:

def cond(x, y):
    if x<y:
        return "Accepté"
    else:
        return "Rejeté"

To construct a function, you have to use def Python statement.

def cond(x, y):
    if x<y:
        print("Accepté")
    else:
        print("Rejeté")

EDIT given the comment, it seems that you do not want to only print the result, but you want the function to return the string. So, here it is:

def cond(x, y):
    if x<y:
        return "Accepté"
    else:
        return "Rejeté"

All this is pure Python. Let me suggest to read some introductions about this generic language, since Sage is based on it, and you will benefit a lot to make clever constructions out of Sage mathematical bricks.