Python tools for doing stuff with letters.
Project description
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
Another example for randomly picking a letter out of numbers.
>>> from letter_tools import randlet
>>> rand(4, 8)
h
>>> rand(5, 7)
e
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
Usage
Word score could help you make 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for letter_tools-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e987001a8e936f5fbeef141552aa1bb65b681bc57ca7600b318e27291b4bde6 |
|
MD5 | d133e847a766adb5fe1ce9a0af5147c7 |
|
BLAKE2b-256 | 1a30e3f153b62feb5dc58087938b51f2b809fd42ece4e55c2ad2fcc1a3eb59b3 |