Files

33 lines
1.3 KiB
Python
Raw Permalink Normal View History

2026-08-27 11:04:42 -06:00
import random, string
def rand_str(min_len=5, max_len=10, charset=None):
if charset is None:
charset = string.ascii_letters + string.digits
length = random.randint(min_len, max_len)
return ''.join(random.choice(charset) for _ in range(length))
def rand_var(min_len=6, max_len=12):
first = random.choice(string.ascii_letters)
rest = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(min_len-1, max_len-1)))
return first + rest
def rand_label(min_len=5, max_len=10):
chars = string.ascii_letters + string.digits + '[]{}()_'
first = random.choice(string.ascii_letters)
rest = ''.join(random.choice(chars) for _ in range(random.randint(min_len-1, max_len-1)))
return first + rest
def rand_word():
vowels = 'aeiou'
consonants = 'bcdfghjklmnpqrstvwxyz'
length = random.randint(3, 12)
word = ''
for i in range(length):
word += random.choice(consonants) if i % 2 == 0 else random.choice(vowels)
return word
def rand_words(min_count=3, max_count=10):
return ' '.join(rand_word() for _ in range(random.randint(min_count, max_count)))
def rand_case(s):
return ''.join(c.upper() if random.random() > 0.5 else c.lower() for c in s)