Book Image

Sage Beginner's Guide

By : Craig Finch
1 (1)
Book Image

Sage Beginner's Guide

1 (1)
By: Craig Finch

Overview of this book

Table of Contents (17 chapters)
Sage Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Operators and variables


Operators and variables are two fundamental elements of numerical computing. Sage uses the Python programming language as the interface for all of its components, so writing code for Sage is very similar to writing Python code. Sage extends the Python language with additional types that are well suited for mathematical calculations. In this section, we'll learn more about how operators and variables work in Sage.

Arithmetic operators

The following table lists the operators that are available in Sage:

Operator

Function

Operator

Function

=

Assignment

==

Equality

+

Addition

>

Greater than

-

Subtraction

>=

Greater than or equal to

*

Multiplication

<

Less than

/

Division

<=

Less than or equal to

** or ^

Power

!=

Not equal to

%

Modulo (remainder)

  

//

Integer quotient

  

Note that the assignment operator is a single equal sign, while the test for equality is a double equal sign. The following example illustrates the difference...