Question

In: Other

Mad Libs are activities that have a person provide various words, which are then used to...

Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is quit 0.

# in python

Solutions

Expert Solution

#code

def main():
    #reading a line of text and splitting by white space to create a list of two tokens
    fields=input().split(' ')
    #looping until the first word is 'quit' in any case
    while fields[0].lower()!='quit':
        #displaying in the format 'Eating   a day keeps the doctor away.'
        #assuming that there will always be 2 values in input string separated by space
        print('Eating {} {} a day keeps the doctor away.'.format(fields[1],fields[0]))
        # reading next line of text and splitting by white space
        fields = input().split(' ')

#invoking main() method
main()

#output (user input in green text)


Related Solutions

The following activities and transactions are typical of those that may affect the various funds used...
The following activities and transactions are typical of those that may affect the various funds used by a typical municipal government. Required:Prepare journal entries to record each transaction and identify the fund in which each entry is recorded. A.The Greenville City Council passed a resolution approving a general operating budget of $5,000,000 for the fiscal year 2015. Total revenues are estimated at $4,900,000. B.The Greenville City Council Passed an ordinance providing a property tax levy of $6.25 per $100 of...
How can the activity rates (i.e.cost per activity) for the various activities be used to target...
How can the activity rates (i.e.cost per activity) for the various activities be used to target process improvement? Give examples to support your position. Are there any barriers to using activity based costing in decision making? If so, what are they and can they be overcome with strong management support?
How can the activity rates (i.e.cost per activity) for the various activities be used to target...
How can the activity rates (i.e.cost per activity) for the various activities be used to target process improvement? Give examples to support your position.
How do the various aspects of functional fitness affect daily activities? In other words, how can...
How do the various aspects of functional fitness affect daily activities? In other words, how can a lack of balance, agility, coordination, reaction time, and proprioception affect daily activities?
Discuss the various databases available in the GCU library. Which ones have you used before? What...
Discuss the various databases available in the GCU library. Which ones have you used before? What do you like about them? What do you not like about them?
Various dimensions have been used to define and measure quality. Which three would be most important...
Various dimensions have been used to define and measure quality. Which three would be most important from the patient’s perspective? Which three would be most important from the physician’s perspective? Why?
true or false, the person who provide a report on the extent to which a company's...
true or false, the person who provide a report on the extent to which a company's financial statement faily prsents it financial perfomance and financial position at any given point in time is the internal Auditor
Topic: Person-to-person viral diseases Provide an example of a pathogen in the category. Provide the genus...
Topic: Person-to-person viral diseases Provide an example of a pathogen in the category. Provide the genus and species of the pathogen, along with the name of the illness the pathogen causes in humans. From an epidemiological perspective, why is this pathogen a human health threat?
Discuss the various types of business-type funds used in governmental units and provide an example of...
Discuss the various types of business-type funds used in governmental units and provide an example of when each is appropriate. Include how monitoring and reporting of business-type funds is similar and how it differs from the same functions in a corporation.
Discuss the various types of business-type funds used in governmental units and provide an example of...
Discuss the various types of business-type funds used in governmental units and provide an example of when each is appropriate. Include how monitoring and reporting of business-type funds is similar and how it differs from the same functions in a corporation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT