Ask Your Question
0

How to print equations and numbers on a single line:

asked 2017-01-04 13:17:37 -0600

updated 2017-01-04 14:43:14 -0600

I am trying to print a string, an equation and a number on the same line using the following form:

 B=var('B')
 fce=var('fce', latex_name='f_{ce}')
 fce=2.80e6 * B
 values={B:1.0e5}
 print "Electron Gyrofrequency=", show(fce) , "= %0.5e" % fce.substitute(values)

However the output does not show as a single line. Any help would be appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-01-04 15:11:49 -0600

Try this:

 show( "Electron Gyrofrequency=", fce , "= %0.5e" % fce.substitute(values) )
edit flag offensive delete link more

Comments

Didn't work stuff after "Electron Gyrofrequency=" was not displayed

lookin03820 gravatar imagelookin03820 ( 2017-01-04 16:09:43 -0600 )edit

It works for me. Which Sage interface are you using ?

tmonteil gravatar imagetmonteil ( 2017-01-04 20:11:28 -0600 )edit

sage 6.3 on a mac 10.7.5

lookin03820 gravatar imagelookin03820 ( 2017-01-05 08:42:01 -0600 )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

Stats

Asked: 2017-01-04 13:17:37 -0600

Seen: 50 times

Last updated: Jan 04