Letter Tools
Intro
This is a collection of tools for doing stuff with letters.
With a randint for letters and a range for letters and more.
Installing
To install use this command:
$ pip install letter-tools
Examples
First an example for randomly picking a letter.
>>> from letter_tools import rand
>>> rand("a", "h")
c
>>> rand("a", "h")
g
>>> rand(1, 10)
5
>>> rand(1, 10)
7
Next an example for ranges.
>>> from letter_tools import range
>>> for i in range("i"):
... print(i)
...
a
b
c
d
e
f
g
h
i
>>> for i in range("d", "g"):
... print(i)
...
d
e
f
g
>>> for i in range(1, 5):
... print(i)
...
1
2
3
4
5
#Using step
>>> for i in range(1, 5, 3):
... print(i)
...
1
4
>>> for i in range("d", "g", 3):
... print(i)
...
d
g
Now an example for word score.
# Find the score of a word a=1, b=2 and add up the numbers for all the letters
>>> from letter_tools import word_score
>>> print(word_score("hi"))
17
>>> print(word_score("letter"))
80
>>> print(word_score("hi", opt=""))
37
>>> print(word_score("letter", opt=""))
82
Here we will use the scrabble score, it does almost the same thing as word score but it uses scrabble scoring rules. a: 1, b: 3, c: 3, d: 2, e: 1, f: 4, g: 2, h: 4, i: 1, j: 8, k: 5, l: 1, m: 3, n: 1, o: 1, p: 3, q: 10, r: 1, s: 1, t: 1, u: 1, v: 4, w: 4, x: 8, y: 4, z: 10
>>> from letter_tools import scrabble_score
>>> print(scrabble_score("hi"))
5
>>> print(scrabble_score("letter"))
6
Now for the derandomize and randomize functions.
>>> # For this we will use a word 'welcome' and randomize it.
>>> from letter_tools import randomize
>>> randomize("welcome")
'mlcoeew'
>>> # Now we will derandomize 'mlcoeew'
>>> from letter_tools import derandomize
>>> derandomize("mlcoeew")
['welcome']
Now for custom score.
>>> from letter_tools import custom_score
>>> custom_score('letter', {'l': 13, 'e': 7, 't': 16, 'r': 1})
60
Usage
Word score could help you with making a game to find certain scored words. Here is an example for 100 scored words. This will not eliminate invalid words.
from letter_tools import word_score
while True:
word = input("Could you give me some words that add up to 100 exactly?\na=1, b=2 and so on\n")
if word_score(word) == 100:
print(f"{word} is a 100 letter word correct!!!")
break
else:
print(f"{word} is a {word_score(word)} not a 100 letter word wrong.")
We could also make a script to find 100 scored words. For this we will use the requests library and using Dwyl's english word set I generated a json you could use for this.
This is the code:
from letter_tools import word_score
import requests
words = requests.get("https://raw.githubusercontent.com/hostedposted/letter-tools/master/words.json").json()
for i in words:
try:
if word_score(i) == 100:
print(i)
except KeyError:
pass
Metadata
Release files for letter-tools 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| letter-tools-0.2.4.tar.gz | 4.6 kB | Without provenance | Details for letter-tools-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| letter_tools-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for letter_tools-0.2.4-py3-none-any.whl |
Total release size: 9.7 kB
Release files / letter-tools-0.2.4.tar.gz
| Download URL | letter-tools-0.2.4.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4bf2d2d3d7ff368eb2111198251df5a5b899adf0011d6d0a31190c693ac59c7
|
|
BLAKE2b-256 checksum How to use checksums |
a990378b26d80a7641b9f996b97268cb84948504b0f8344cbcddab5e3606355a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / letter_tools-0.2.4-py3-none-any.whl
| Download URL | letter_tools-0.2.4-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66b27bbdd2765c48060da09120a22f0ad4d6a8138c4fd87507e3c40b755d8410
|
|
BLAKE2b-256 checksum How to use checksums |
9b30234fb26ef978baadc0d2703b6b507361d9e6696bd084f896548bc2a32252
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for letter-tools 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.