Loop Example - Pyscript Typing CST Test
Loading…
Loop Example — Pyscript Code
Prints numbers from 1 to 5 using a for loop in PyScript.
<!DOCTYPE html>
<html>
<head>
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
<py-script>
for i in range(1, 6):
print(i)
</py-script>
</body>
</html>Pyscript Language Guide
PyScript is a framework that allows running Python code directly in web browsers using HTML and JavaScript integration. It bridges Python with the web platform, enabling interactive applications without traditional backend setup.
Primary Use Cases
- ▸Embedding Python code in web pages for interactivity
- ▸Educational platforms teaching Python in the browser
- ▸Interactive data visualizations with Python libraries
- ▸Prototyping web apps quickly using Python
- ▸Combining Python and JavaScript for hybrid applications
Notable Features
- ▸Write Python directly in HTML with `<py-script>` tags
- ▸Access JavaScript objects and browser APIs from Python
- ▸Support for popular Python libraries like NumPy, Pandas, and Matplotlib
- ▸Live code execution in browser without server
- ▸Integration with Pyodide for WebAssembly-based Python runtime
Origin & Creator
Created by Anaconda, Inc., first announced in 2022, inspired by the desire to make Python a first-class citizen for web development alongside JavaScript.
Industrial Note
Used in education, prototyping, and interactive demos; suitable for web-based Python experimentation but not yet a replacement for full-scale web frameworks.