Thursday, March 14, 2024

Random poem generator!



This Python script generates 100 poems with random variations (from chatGPT)
---------------------------------------------------------------------------------------------------
import random # Lists of words and phrases for generating poems themes = ["nature", "beauty", "love", "freedom", "hope"] moods = ["serenity", "joy", "melancholy", "inspiration", "wonder"] verbs = ["awakens", "dances", "whispers", "shines", "blooms"] nouns = ["lake", "tree", "sky", "breeze", "flower"] # Function to generate a random poem def generate_poem(): theme = random.choice(themes) mood = random.choice(moods) verb = random.choice(verbs) noun = random.choice(nouns) poem = f"In the {mood} of the {theme},\n{theme.capitalize()} {verb} with a {noun}.\n" for _ in range(4): adjective = random.choice(["tranquil", "golden", "whispering", "gentle", "rippling"]) noun = random.choice(nouns) poem += f"{adjective.capitalize()} {noun}s {verb} nearby.\n" return poem # Generate 100 poems for i in range(1, 101): poem = generate_poem() print(f"Poem {i}:\n{poem}\n")
----------------------------------------------------------------------------------------------------------

No comments: