代码拉取完成,页面将自动刷新
同步操作将从 jack2583/PythonExamples 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""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))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。