SharedTry-Python3-based-SageMath-in-Jupyter.ipynbOpen in CoCalc
Authors: Frédéric Chapoton, Eric Gourgoulhon, Samuel Lelièvre, William A. Stein
Views : 42
Description: Try Python3-based SageMath in Jupyter

Try Python3-based SageMath in Jupyter

Let's check which version of Sage and of Python this is.

In [1]:
print(version()) # SageMath version
SageMath version 8.4.rc0, Release Date: 2018-10-07
In [2]:
print(sys.version) # Python version
3.6.6 (default, Oct 10 2018, 07:37:57) [GCC 7.3.0]

Let's check some stuff that works differently in Python 2 and Python 3.

In [3]:
range(10)
range(0, 10)
In [4]:
print 2
File "<ipython-input-4-01aef55c34fb>", line 1 print Integer(2) ^ SyntaxError: invalid syntax
In [5]:
print(2)
2

Let's check some Sage functionality

In [6]:
matrix(ZZ, 2)
[0 0] [0 0]
In [7]:
M = ModularSymbols(23)
In [8]:
M
Modular Symbols space of dimension 5 for Gamma_0(23) of weight 2 with sign 0 over Rational Field
In [9]:
M.basis()
((1,0), (1,17), (1,19), (1,20), (1,21))
In [ ]: