import json
def wallis(n):
pi = 2
for i in range(1,n):
pi *= 4 * i ** 2 / (4 * i ** 2 -1)
return pi
pi = wallis(100000)
s = f"Pi is approximately: {pi:.3f}"
print(s)
manual_div = Element("pi")
manual_div.element.innerText = pi
import datetime as dt
pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y'))
Let's Initiate a PyScript Repl
Write some python code in the cell below and press Shift-Enter to have the code evaluated.
Let's Plot Random Numbers
Use python's matplotlib to plot some randomly generated coordinates.
import matplotlib.pyplot as plt
from data import make_x_and_y
x, y = make_x_and_y(n=100)
fig, ax = plt.subplots()
ax.scatter(x,y)
fig