forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
random-sentences.py
43 lines (32 loc) · 1.16 KB
/
random-sentences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Generates Random Sentences
Creates a sentence by selecting a word at randowm from each of the lists in
the following order: 'article', 'nounce', 'verb', 'preposition',
'article' and 'noun'.
The second part produce a short story consisting of several of
these sentences -- Random Note Writer!!"""
import random
article = ["the", "a", "one", "some", "any"]
noun = ["boy", "girl", "dog", "town", "car"]
verb = ["drove", "jumped", "ran", "walked", "skipped"]
preposition = ["to", "from", "over", "under", "on"]
def random_int():
return random.randint(0, 4)
def random_sentence():
"""Creates random and return sentences."""
return (
"{} {} {} {} {} {}".format(
article[random_int()],
noun[random_int()],
verb[random_int()],
preposition[random_int()],
article[random_int()],
noun[random_int()],
)
).capitalize()
# prints random sentences
for sentence in list(map(lambda x: random_sentence(), range(0, 20))):
print(sentence)
print("\n")
story = (". ").join(list(map(lambda x: random_sentence(), range(0, 20))))
# prints random sentences story
print("{}".format(story))