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 ed494aa

Browse files
Create README.md
1 parent 12b9fa1 commit ed494aa

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎Story Generator/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Story Generator🔥
2+
3+
Do you think the most complex use of the random module in Python is random sampling? No, we can also generate random stories or anything beyond that using the random module.
4+
5+
## 📌Story Generator with Python
6+
Our task is to generate a random story every time the user runs the program. I will first store the parts of the stories in different lists, then the Random module can be used to select the random parts of the story stored in different lists:
7+
8+
**Code**
9+
10+
import random
11+
when = ['A few years ago', 'Yesterday', 'Last night', 'A long time ago','On 20th Jan']
12+
who = ['a rabbit', 'an elephant', 'a mouse', 'a turtle','a cat']
13+
name = ['Ali', 'Miriam','daniel', 'Hoouk', 'Starwalker']
14+
residence = ['Barcelona','India', 'Germany', 'Venice', 'England']
15+
went = ['cinema', 'university','seminar', 'school', 'laundry']
16+
happened = ['made a lot of friends','Eats a burger', 'found a secret key', 'solved a mistery', 'wrote a book']
17+
print(random.choice(when) + ', ' + random.choice(who) + ' that lived in ' + random.choice(residence) + ', went to the ' + random.choice(went) + ' and ' + random.choice(happened))
18+
19+
**Output:**
20+
21+
On 20th Jan, a rabbit that lived in Germany, went to the laundry and made a lot of friends
22+
23+
Here, I first imported the random module and then I created parts of the stories in different lists, then I only selected the parts of the lists at random to generate a random story.
24+
25+
As a beginner, you look for creating software applications more, which is not wrong. But spending more time with programs which required you to think logically will always help you no matter what aspect of programming interests you.
26+
27+
## 📌Summary
28+
There are a few areas where the above code could be improved upon, but at a basic level, it meets many secure password generation requirements by today’s standards.
29+
30+
As a newbie to Python or any other language, you should keep trying these types of programs as they help you explore more functions and in the long run will help you design your algorithms and doing a great job in coding interviews.

0 commit comments

Comments
(0)

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