Ask Your Question

Revision history [back]

Well, using Python exceptions, you may define a division function like this:

def div(x,y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1

It yields

sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1

Well, using Python exceptions, you may define a division function like this:

def div(x,y):
div(x, y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1

It yields

sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1

Well, using Python exceptions, you may define a division function like this:

def div(x, y):
    try:
         return x/y
    except ZeroDivisionError:
         return 1

It yields

sage: div(2,3)
2/3
sage: div(2,0)
1
sage: div(x,x-x)
1