#!/usr/bin/env python # coding: utf-8 # # Python kernel backed by Pyodide # # ![](https://raw.githubusercontent.com/pyodide/pyodide/master/docs/_static/img/pyodide-logo.png) # In[ ]: import pyodide_kernel pyodide_kernel.__version__ # ## Display # In[ ]: from IPython.display import Markdown, HTML, JSON, Latex # ## HTML # In[ ]: print("Before display") s = "

HTML Title

" display(HTML(s)) print("After display") # ## Markdown # In[ ]: Markdown( """ # Title **in bold** ~~Strikthrough~~ """ ) # ## Latex # In[ ]: Latex( r"""\begin{eqnarray} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{eqnarray}""" ) # # Matplotlib # # Basic static plotting (temp patch) # In[ ]: import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) plt.plot(x, np.sin(x)) plt.show() # ## Pandas DataFrame # In[ ]: import pandas as pd import numpy as np from string import ascii_uppercase as letters df = pd.DataFrame(np.random.randint(0, 100, size=(100, len(letters))), columns=list(letters)) df # ### Show the same DataFrame # In[ ]: df # ## Network requests and JSON # In[ ]: import json from js import fetch # In[ ]: res = await fetch("https://httpbin.org/get") text = await res.text() obj = json.loads(text) JSON(obj) # ## Sympy # In[ ]: from sympy import Integral, sqrt, symbols, init_printing init_printing() x = symbols("x") Integral(sqrt(1 / x), x) # In[ ]: