First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

def cond(x, y):
    if x<y:
        print("Accepté")
    else:
        print("Rejeté")
click to hide/show revision 2
No.2 Revision

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é"
click to hide/show revision 3
No.3 Revision

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.