To evaluate the below equation. Put your cursor into the cell and press Shift+Enter.
2 + 3 + 6^2 + sin(2)
Try again.
r = 2 + 3 + 6^2 + sin(2)
This seems to do nothing, but it has assigned this value to the variable $r$. We can see it by printing $r$.
r
But maybe we want a decimal expression for it. The variable $r$ is now a real number. There are functions we can apply on real numbers. Many of them are written in the form $\sin(r)$ others are written in the form $r$.show(). To get a decimal approximation of a real we use the .n() function.
r.n()
Often I like to see the results when I define a variable. The semicolon allows multiple commands at once.
n = factorial(7); n
To write a nice comment like this, open a new evaluation cell change its type to markdown. This tells sage to interpret it as markdown. When you are finished, type "Shift+Enter" to leave. To edit it, double click on it. You can use html and you can use $\LaTeX{}$ to prettify your math: $\phi(x) = \frac{1}{\ln{x}}$.
Sage has all sorts of build in functions.
2^6
factor(60)
prime_factors(60)
type(n)
n.binary()
See what else you can do with an integer. Go up to the above cell and erase upto the n. then press 'Tab'. YOu will get a list of possible functions. If you try to use one like n.binary without the () you will get an error. Some of them, like n.binomial need an argument: n.binomial(2) gives you n choose 2.
n.prime_factors()
pf = n.prime_factors(); pf
pf.index(5)
pf.append('a'); pf
pf.count(3)
pf.append(3); pf
pf.count(3)
pf.index(3)
pf[2]