Ask Your Question
1

String Output from Multiple Function Calls

asked 2022-11-22 19:05:03 +0100

rslitman gravatar image

Web page SageMathCell, sagecell dot sagemath dot org slash ?q=bfdjbp - This one opens with particular function/subroutine calls already typed in. Someone supplied it to me in response to a question I posted in Mathematics Stack Exchange. I took it from there, reading up on various function/subroutine calls for SageMath. I am a longtime mainframe programmer (COBOL mainly), but I did get some exposure to object-oriented programming (but not in Python) before my retirement. Please excuse me if I have misused the terms subroutine and function here.

The code I was supplied is:

E = EllipticCurve([0,0,0,-3,34])

E.integral_points()

I learned about the rank() call and wanted to add it:

E.rank()

However, only the second one displays. I comment-out (using "#", which I was able to learn about through Googling) the line I don't use. But what I'd really like to do is to display both E.integral_points() and E.rank() at the same time.

Using pseudocode, what some of my earlier programming experience would have me do is something like this:

E.integral_points() + E.rank()

or maybe:

String(E.integral_points(), E.rank())

If you understand what I am trying to do, please let me know how to do it. Or if it can't be done, please let me know. Thanks in advance for any emoticon-free, emoji-free response you can give me.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2022-11-23 08:33:40 +0100

vdelecroix gravatar image

SageMathCell behaves similarly to Jupyter: the output of a cell is the result of the last command in that cell. If you want to display something, use the Python function print such as

print(E.integral_points())
print(E.rank())
edit flag offensive delete link more

Comments

Thank you. This worked for me. I have never heard of Jupyter. My professional object-oriented experience, after my last pre-retirement employer began phasing out mainframes and COBOL, was to a proprietary system based on Java.

rslitman gravatar imagerslitman ( 2022-11-25 03:37:18 +0100 )edit
1

answered 2022-11-23 19:10:50 +0100

Emmanuel Charpentier gravatar image

You may also build a list, tuple or dictionary regrouping your desired results ; e. g. :

{"Integral points":E.integral_points(), "Rank":E.rank()}

This dictionary :

  • is self-documented, and

  • still a Python object, reusable at will...

HTH,

edit flag offensive delete link more

Comments

Thanks, this worked for me, too.

rslitman gravatar imagerslitman ( 2022-11-25 03:40:35 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-11-22 19:05:03 +0100

Seen: 170 times

Last updated: Nov 23 '22