Beginner Python Projects: Build a Simple Random Story Generator

Beginner Python Projects: Build a Simple Random Story Generator

Our random story generator will use a few lists of phrases and every time we run our program, a sentence will be randomly formed by picking phrases from them.

Hey amazing people, today let's build a Random Story Generator using Python.

How Our Story Generator works

Our random story generator will use a few lists of phrases and every time we run our program, a sentence will be randomly formed by picking phrases from those lists. Again it's a fun and easy project so let's get into coding.

Let's Code

For this project, as we are going to randomly pick phrases, we need a module that can make our job easy. Any guesses which module I mean?

The random module! random module comes pre-installed with python hence we don't have to manually install it. Let's import it into our project.

import random

Now it's time to define our lists which will contain random phrases.

when = ['A long time ago', 'Yesterday', 'Before you were born', 'In future', 'Before Thanos arrived']
who = ['Shazam', 'Iron Man', 'Batman', 'Superman', 'Captain America']
went = ['Arkham Asylum', 'Gotham City', 'Stark Tower', 'Bat Cave', 'Avengers HQ']
what = ['to eat a lot of cakes', 'to fight for justice', 'to steal ice cream', 'to dance']

python python-programming python-tutorials projects

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

How to Remove all Duplicate Files on your Drive via Python

Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Guide to Python Programming Language

Guide to Python Programming Language

Python Hello World Program - Create & Run Your First Python Program in PyCharm

Python Hello World Program - Your first step towards Python world. Learn how to create the Hello World Python program in PyCharm.