Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 562156f

Browse files
Story generator script is added
1 parent d8a3794 commit 562156f

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

‎SCRIPTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@
100100
| 96\. | Sorting Techniques | Sorting techniques are scripts that arrange a collection of data elements in a particular order, typically ascending or descending. | [Take Me](./Sorting%20Techniques/) | [Himanshu Agarwal](https://github.com/himanshu-03)
101101
| 99\. | File Organizer script | A File Organizer script is a program or script that automates the process of organizing files within a directory or multiple directories | [Take Me](./File Organizer script/) | [Abhinav kumar](https://github.com/Abhinavcode13)
102102
| 100\. | File Encryption/Decryption script | A File Organizer script is a program or script that automates the process of organizing files within a directory or multiple directories | [Take Me](./File Encryption/Decryption script/) | [Abhinav kumar](https://github.com/Abhinavcode13)
103+
| 101\. |Story Generator | This script randomly selects a character, setting, action, and conclusion from predefined lists and generates a story using these elements. | [Take Me](./Story_Generator/story_generator.py) | [Shraddha Singh](https://github.com/shraddha761)
103104

‎Story_Generator/Readme.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Story Generator
2+
3+
This is a simple Python script that generates random stories by combining predefined characters, settings, actions, and conclusions. Each time the script is run, it generates a unique story.
4+
5+
## How to Use
6+
7+
1. Make sure you have Python installed on your system.
8+
2. Clone or download this repository to your local machine.
9+
3. Open a terminal or command prompt and navigate to the project directory.
10+
4. Run the script using the following command:
11+
5. The script will generate a random story and display it in the terminal.
12+
13+
## Customization
14+
15+
You can customize the story generator by modifying the predefined lists in the script. Here's what each list represents:
16+
17+
- `characters`: A list of characters that can be the protagonist or main characters of the story.
18+
- `settings`: A list of different settings or locations where the story can take place.
19+
- `actions`: A list of actions or events that can happen in the story.
20+
- `conclusions`: A list of possible endings or conclusions to the story.
21+
22+
23+
Each story generated will have a similar structure but with different elements randomly chosen from the lists.
24+
25+

‎Story_Generator/story_generator.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import random
2+
3+
# Lists of story elements
4+
characters = ['Alice', 'Bob', 'Charlie', 'Eve']
5+
settings = ['a small town', 'a mysterious castle', 'a futuristic city', 'an enchanted forest']
6+
actions = ['discovered a hidden treasure', 'solved a puzzling mystery', 'overcame their fears', 'saved the world']
7+
conclusions = ['and they lived happily ever after.', 'and they vowed to continue their adventures.', 'and they returned home, forever changed.']
8+
9+
# Generate a random story
10+
def generate_story():
11+
character = random.choice(characters)
12+
setting = random.choice(settings)
13+
action = random.choice(actions)
14+
conclusion = random.choice(conclusions)
15+
16+
story = f"Once upon a time, {character} found themselves in {setting}. They {action} {conclusion}"
17+
18+
return story
19+
20+
# Generate and print a story
21+
story = generate_story()
22+
print(story)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /