Page 1 of 1

JupyterLite and PyScript: Python in the Browser

Posted: Sun May 01, 2022 9:29 pm
by Eli
Thanks to Anaconda and other giants for this amazing possibility - Python in the browser!

Temporarily disabled PyScript for improvement.

You can still use Python here


JupyterLite





Sage Cell


Re: PyScript: Python in the Browser

Posted: Tue May 03, 2022 5:04 pm
by Eli
Test These examples

Given the list of integers, X, write code to count how many integers are strictly larger than all the integers to their right. Exclude the last digit since it doesn’t have a number to its right. E.g. for [2,3,1] the answer should be 1 while for [12,4,4,2,2,3] the answer is 2.

In Python the code may look like (Use other languages):

  1. X = [7,9,5,3,2,4,5,0]
  2.  
  3. def current_max(X):
  4.     m = 0
  5.     for i in X[::-1]:
  6.         m = max(m, i)
  7.         yield m
  8. N_int = sum([x>y for x,y in zip(X[-2::-1], current_max(X))])
  9. print(N_int)


  1. import matplotlib.pyplot as plt
  2. x = [7,9,5,3,2,4,5,0]
  3. y = [7,9,5,3,2,4,5,0]
  4. fig, ax = plt.subplots()
  5. ax.scatter(x, y)
  6. fig