JavaScript for Python Developers
npm install pyscript-js
Use python functions now in JavaScript
Report bug
·
Request feature
Place it just above the end body tag above all the script tags
``js`
- Download the latest release
- Clone the repo: git clone https://github.com/Yaseen549/pyscript-js.gitnpm i pyscript-js
- Install with npm: yarn add pyscript-js
- Install with yarn:
Read the Getting started page for information on the Library contents, examples, and more.
python
input()
print() # Will override print() in JavaScript
jsprint() # to use native js print() method
int()
float()
str()
chr() # Takes single value eg: chr(95)
chr([]) # Multiple Values as Array eg: print(chr([65,66]))
ascii() # getting ascii values from string values. eg: ascii("a")
hex()
len()
round()
max()
min()
sum([])
sorted()
type()
pow()
abs()
range() # range(1,10) or range("a","z")random class
random.randint()
random.randrange()
random.choice()
random.shuffle()dot functions
"".upper()
"".lower()
"".title()
"".capitalize()
[].append()
[].extend()
[].index() # find index value of an item in list
"".index() # find index value of a value in String
[].insert()
[].clear()
[].count()
[].remove()
[].copy()in-built existing Js functions of Python
"".join()
"".split()
[].sort()
[].pop()
[].reverse()Play Around functions
"".charList() # converts string into list of characters
"".wordList() # converts string(Sentence) into list of Strings(words)En-glishers
alphabet() # Returns alphabet from "a" to "z"
vowels() # Returns vowels or Array/list. Eg: let a = vowels()/ a = vowels("Hello")
consonants() # Returns consonants or from [list/Array]/"String"`$3
index.html
`html
PyScript.js
...
`
script.js`js
// script.js file
// program to generate fibonacci series up to n terms// take input from the user
number = int(input('Enter the number of terms: '));
n1 = 0,
n2 = 1,
nextTerm = 0;
print('Fibonacci Series:');
for (let i = 1; i <= number; i++) {
print(n1);
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
`$3
Within the download you'll find the following directories and files, logically grouping common assets. You'll see something like this:`
PyScript-js/
└── dist/
└── js/
├── pyscript-node.js
├── pyscript-node.min.js
├── pyscript.js
└── pyscript.min.js
``
Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.