From 2aa6d691ce373363cfeb83e3eefeeec50343ec9f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 7 May 2022 00:16:48 +0200 Subject: [PATCH] GETTING-STARTED: Dedentation is no longer required #130 makes Python fit right into the existing HTML indentation just like JavaScript. --- GETTING-STARTED.md | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index d9ad395b693..1fc3dd71b6a 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -55,18 +55,18 @@ example, we can compute π. - -print("Let's compute π:") -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"π is approximately {pi:.3f}" -print(s) - + + print("Let's compute π:") + 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"π is approximately {pi:.3f}" + print(s) + ``` @@ -94,17 +94,17 @@ the `` tag write to.
-import datetime as dt -pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y')) + import datetime as dt + pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y')) -def wallis(n): - pi = 2 - for i in range(1,n): - pi *= 4 * i ** 2 / (4 * i ** 2 - 1) - return pi + def wallis(n): + pi = 2 + for i in range(1,n): + pi *= 4 * i ** 2 / (4 * i ** 2 - 1) + return pi -pi = wallis(100000) -pyscript.write('pi', f'π is approximately {pi:.3f}') + pi = wallis(100000) + pyscript.write('pi', f'π is approximately {pi:.3f}') @@ -146,15 +146,15 @@ as a shortcut, which takes the expression on the last line of the script and run

Let's plot random numbers

-import matplotlib.pyplot as plt -import numpy as np + import matplotlib.pyplot as plt + import numpy as np -x = np.random.randn(1000) -y = np.random.randn(1000) + x = np.random.randn(1000) + y = np.random.randn(1000) -fig, ax = plt.subplots() -ax.scatter(x, y) -fig + fig, ax = plt.subplots() + ax.scatter(x, y) + fig @@ -196,14 +196,14 @@ In the HTML tag `` paths to local modules are provided in the

Let's plot random numbers

-import matplotlib.pyplot as plt -from data import make_x_and_y + import matplotlib.pyplot as plt + from data import make_x_and_y -x, y = make_x_and_y(n=1000) + x, y = make_x_and_y(n=1000) -fig, ax = plt.subplots() -ax.scatter(x, y) -fig + fig, ax = plt.subplots() + ax.scatter(x, y) + fig