396,778 views
16 votes
16 votes
100 POINTS FOR ANYONE WHO CAN DO THIS!

Make the following modifications to the original sentence-generator program:

The prepositional phrase is optional. (It can appear with a certain probability.)
A conjunction and a second independent clause are optional: "The boy took a drink and the girl played baseball".
An adjective is optional, it may or may not be added to the sentence to describe a noun: "The girl kicked the red ball with a sore foot".
"Optional" is implying that the program should include these elements in a semi-random frequency.

You should add new variables for the sets of adjectives and conjunctions.

100 POINTS FOR ANYONE WHO CAN DO THIS! Make the following modifications to the original-example-1
User Abhishek Ghimire
by
2.5k points

1 Answer

27 votes
27 votes

Let's check what can be modified

Before calling def we need adjective and conjunctions stored inside variables

Store them(You may change according to your choice)


\tt adjectives=(


\tt conjunctions=(

We have to make optional ,easy way ask the user to do instead of yourself .


\tt con=input(


\tt adj=input(

If they click then we can proceed else no problem let the program run


\tt def\: conjunctionPhrase():


\quad\tt if\: con==


\quad\quad\tt return\:random.choice(conjunctions)+


\quad\tt else:


\quad\quad\tt continue

  • You may use pass also


\tt def\: adjectivePhrase():


\quad\tt if\:adj==


\quad\quad\tt return\:random.choice(adjectives)+


\quad\tt else:


\quad\quad\tt continue

User TheRealKingK
by
2.7k points