First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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

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