Thứ Bảy, 27 tháng 8, 2022

pyscript

- numpy

import numpy as np from js import document import urllib #Nhập n n = 8 Y = '$$\\begin{tikzpicture}[yscale=0.87]' #Xử lý xuất kết quả for i in range(n+1): for j in range(i+1): x = j-0.5*i y = n - i a = 'C_{'+str(i)+'}^{'+str(j)+'}' Y = Y + '\n\\path ('+str(x)+','+str(y)+') node[circle,draw=cyan]{\\color{red}{$'+str(a)+'$}};' Y = Y + '\n\\end{tikzpicture}$$' path = 'https://i.upmath.me/svg/' + urllib.parse.quote(Y, safe='') i = document.createElement('img') i.setAttribute('src', path) i.setAttribute('class', 'latex-svg') i.setAttribute('style', 'vertical-align: calc(var(--latex-zoom, 1)*-79.875pt); border: 0px; opacity: 1; width: calc(var(--latex-zoom, 1)*178.5pt); height: calc(var(--latex-zoom, 1)*159.75pt);') i.setAttribute('alt', Y) ex = document.getElementById('pi').appendChild(i)

Thứ Năm, 25 tháng 8, 2022

matplotlib

- matplotlib

# Python Code # importing the matplotlib library import matplotlib.pyplot as plt fig, ax = plt.subplots() # x axis x = ["Python", "C++", "JavaScript", "Golang"] # y axis y = [10, 5, 9, 7] plt.plot(x, y, marker='o', linestyle='-', color='b') # Naming the x-label plt.xlabel('Language') # Naming the y-label plt.ylabel('Score') # Naming the title of the plot plt.title('Language vs Score') fig

Mẫu Pyscript

- numpy

$$\begin{tikzpicture} \path (0.0,6) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-0.5,5) node[circle,draw=cyan]{\color{red}{$1$}}; \path (0.5,5) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-1.0,4) node[circle,draw=cyan]{\color{red}{$1$}}; \path (0.0,4) node[circle,draw=cyan]{\color{red}{$1$}}; \path (1.0,4) node[circle,draw=cyan]{\color{red}{$2$}}; \path (-1.5,3) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-0.5,3) node[circle,draw=cyan]{\color{red}{$1$}}; \path (0.5,3) node[circle,draw=cyan]{\color{red}{$2$}}; \path (1.5,3) node[circle,draw=cyan]{\color{red}{$6$}}; \path (-2.0,2) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-1.0,2) node[circle,draw=cyan]{\color{red}{$1$}}; \path (0.0,2) node[circle,draw=cyan]{\color{red}{$2$}}; \path (1.0,2) node[circle,draw=cyan]{\color{red}{$6$}}; \path (2.0,2) node[circle,draw=cyan]{\color{red}{$24$}}; \path (-2.5,1) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-1.5,1) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-0.5,1) node[circle,draw=cyan]{\color{red}{$2$}}; \path (0.5,1) node[circle,draw=cyan]{\color{red}{$6$}}; \path (1.5,1) node[circle,draw=cyan]{\color{red}{$24$}}; \path (2.5,1) node[circle,draw=cyan]{\color{red}{$120$}}; \path (-3.0,0) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-2.0,0) node[circle,draw=cyan]{\color{red}{$1$}}; \path (-1.0,0) node[circle,draw=cyan]{\color{red}{$2$}}; \path (0.0,0) node[circle,draw=cyan]{\color{red}{$6$}}; \path (1.0,0) node[circle,draw=cyan]{\color{red}{$24$}}; \path (2.0,0) node[circle,draw=cyan]{\color{red}{$120$}}; \path (3.0,0) node[circle,draw=cyan]{\color{red}{$720$}}; \end{tikzpicture}$$

H-Maths

import numpy as np from js import document #Nhập n n = 6 Y = '$$\\begin{tikzpicture}' #Xử lý xuất kết quả for i in range(n+1): for j in range(i+1): x = j-0.5*i y = n - i a = int(np.math.factorial(j)) Y = Y + '\n\\path ('+str(x)+','+str(y)+') node[circle,draw=cyan]{\\color{red}{$'+str(a)+'$}};' Y = Y + '\n\\end{tikzpicture}$$' paragraph = document.getElementById('pi') paragraph.innerText = Y paragraph.contentWindow.location.reload(true)

H-Maths

def runPython(*args): pyscript.write("tpi", "$$\begin{tikzpicture}\path (0.0,6) node[circle,draw=cyan]{\color{red}{$1$}};\end{tikzpicture}$$")