Question

In: Computer Science

THIS PROGRAM I HAVE MADE UP CHOOSES A RANDOM STORY AND IS IN MAD LIBS FORMAT....

THIS PROGRAM I HAVE MADE UP CHOOSES A RANDOM STORY AND IS IN MAD LIBS FORMAT.

IM HAVING A DIFICULT TIME FORMING A ALGORITHIM FOR THE PROGRAM. if you coukd develop a algorithim it will be greatly appreciated.

Thank you,

# Dillon Montefusco, A, B

# need to write up a Mad Libs story itself.

# looping input where it prompts for a type of word

# need to write entire scripts (stories)

# use random to choose a story, so the user cannot read it and can enjoy with his friends also the story.



import random as r # for the story randomize agent

ri = r.randint



def okt(b): # octal number converter (ALL RIGHTS RESERVED, THIS FUNCTION IS OFF THE INTERNET)

n = int(b)

r = ''

while n > 0:

r = str(n % 8) + r

n //= 8

if r: return r

return '0'



def get_story(): # This is the story randomize agent

return ri(1, 0o3)



def word_prompt(pos): # part of speech

"""Function takes a word type (part of speech) and returns the word to be inserted in the mainString."""

word = input("Enter a "+str(pos)+": ")

if pos == 'name' or pos == 'male' or pos == 'female' or pos == 'city':

return word.title()

else:

return word.lower()



# THIS IS STORY 01 OF 20

def story01():

wp = word_prompt

story01 = "While going down the "+str(wp('name'))+" Bridge to "+str(wp('city'))+", something out-of-the-ordinary happened... \n\

a bunch of "+str(wp('plural noun'))+" were "+str(wp('verb'))+" over the traffic! It was pretty wierd,\n\

and definitely a "+str(wp('adjective'))+" sight to see, but I guess that's one way to beat the "+str(wp("adjective"))+" traffic. \n\

Man, I wish I could do the same."

return story01


def story02():

wp = word_prompt

story02 = "Homeboy "+str(wp('male'))+" pulled up to the "+str(wp('place'))+" and bought "+str(wp('number'))+" lottery tickets. \n\

Litte did he know, one of the tickets was a "+str(wp('adjective'))+" winner! \nOnce he checked the tickets, homeboy got so happy! \n\

Matter of fact, he was so happy that he "+str(wp('verb'))+" all the way home, \nbut dropped the winning ticket on the way. Long story short, he never got his money. \n\

Sucks to suck, doesn't it?"

return story02


def story03():

wp = word_prompt

story03 = "Back in the olden times there was a "+str(wp('mystical creature'))+" named "+str(wp('name'))+" that \

lived in a "+str(wp('adjective'))+" cave. \nIt was hella dusty in there, and the poor homie had \

trouble breathing. \nBut fear no more, because a "+str(wp('adjective'))+" wizard came through and pulled up with a \nmagical "+str(wp('item'))+" that \

cleaned up the place better than a swiffer sweeper duster! \nIf it wasn't for "+str(wp('male'))+" the Wizard, \

the "+str(wp('mystical creature'))+" would've gotten asthma. \nToo bad inhalers weren't invented back then."

return story03


  

# STORY DETERMINER

def story_determiner(count):

count = count

sn = get_story()

story_random = input("Get a random story?: ")

if story_random.lower() == "no":

story_prompt = input("Enter story number: ")

if story_prompt == "1" or story_prompt == "01":

input(story01())

repeat()

if story_prompt == "2" or story_prompt == "02":

input(story02())

repeat()

if story_prompt == "3" or story_prompt == "03":

input(story03())

repeat()

else:

input("Sorry, I can't recognise that story number!")

if count > 3: # hidden message counter

print("Have you really messed up", okt(count), "times!?")

story_determiner(count + 1)

elif story_random.lower() == "yes":

if sn == 1:

input(story01())

repeat()

elif sn == 2:

input(story02())

repeat()

elif sn == 3:

input(story03())

else:

input("Sorry, feature not available in the educational version!")

exit()



# OVERALL PROGRAM LOOP

def repeat():

a = input("Would you like to do another?: ")

if a.lower() == 'yes':

story_determiner(0)

elif a.lower() == 'no':

input("Thanks for playing! Press enter to close.")

else:

print("Bruh, how about you answer the question, eh?")

repeat()



story_determiner(0) # This line begins the program execution

Solutions

Expert Solution

# do comment if any problem arises

# Code

# Dillon Montefusco, A, B

# need to write up a Mad Libs story itself.

# looping input where it prompts for a type of word

# need to write entire scripts (stories)

# use random to choose a story, so the user cannot read it and can enjoy with his friends also the story.

import random as r  # for the story randomize agent

ri = r.randint


def okt(b):  # octal number converter (ALL RIGHTS RESERVED, THIS FUNCTION IS OFF THE INTERNET)

    n = int(b)

    r = ''

    while n > 0:

        r = str(n % 8) + r

        n //= 8

        if r:

            return r

    return '0'


def get_story():  # This is the story randomize agent

    return ri(1, 3)


def word_prompt(pos):  # part of speech

    """Function takes a word type (part of speech) and returns the word to be inserted in the mainString."""

    word = input("Enter a "+str(pos)+": ")

    if pos == 'name' or pos == 'male' or pos == 'female' or pos == 'city':

        return word.title()

    else:

        return word.lower()


# THIS IS STORY 01 OF 20

def story01():

    wp = word_prompt

    story01 = "While going down the "+str(wp('name'))+" Bridge to "+str(wp('city')) + ", something out-of-the-ordinary happened... \n\

    a bunch of "+str(wp('plural noun'))+" were "+str(wp('verb'))+" over the traffic! It was pretty wierd, \n\

    and definitely a "+str(wp('adjective'))+" sight to see, but I guess that's one way to beat the "+str(wp("adjective"))+" traffic. \n\

    Man, I wish I could do the same."

    return story01


def story02():

    wp = word_prompt

    story02 = "Homeboy "+str(wp('male'))+" pulled up to the "+str(wp('place'))+" and bought "+str(wp('number')) + " lottery tickets. \n\

    Litte did he know, one of the tickets was a "+str(wp('adjective'))+" winner! \nOnce he checked the tickets, homeboy got so happy! \n\

    Matter of fact, he was so happy that he "+str(wp('verb'))+" all the way home, \nbut dropped the winning ticket on the way. Long story short, he never got his money. \n\

    Sucks to suck, doesn't it?"

    return story02


def story03():

    wp = word_prompt

    story03 = "Back in the olden times there was a "+str(wp('mystical creature'))+" named "+str(wp('name')) + " that \

    lived in a "+str(wp('adjective'))+" cave. \nIt was hella dusty in there, and the poor homie had \

    trouble breathing. \nBut fear no more, because a "+str(wp('adjective'))+" wizard came through and pulled up with a \nmagical "+str(wp('item'))+" that \

    cleaned up the place better than a swiffer sweeper duster! \nIf it wasn't for "+str(wp('male'))+" the Wizard, \

    the "+str(wp('mystical creature'))+" would've gotten asthma. \nToo bad inhalers weren't invented back then."

    return story03


# STORY DETERMINER

def story_determiner(count):

    count = count

    sn = get_story()

    story_random = input("Get a random story?: ")

    if story_random.lower() == "no":

        story_prompt = input("Enter story number: ")

        if story_prompt == "1" or story_prompt == "01":

            input(story01())

            repeat()

        if story_prompt == "2" or story_prompt == "02":

            input(story02())

            repeat()

        if story_prompt == "3" or story_prompt == "03":

            input(story03())

            repeat()

        else:

            input("Sorry, I can't recognise that story number!")

        if count > 3:  # hidden message counter

            print("Have you really messed up", okt(count), "times!?")

            story_determiner(count + 1)

    elif story_random.lower() == "yes":

        if sn == 1:

            input(story01())

            repeat()

        elif sn == 2:

            input(story02())

            repeat()

        elif sn == 3:

            input(story03())

    else:

        input("Sorry, feature not available in the educational version!")

    exit()


# OVERALL PROGRAM LOOP

def repeat():

    a = input("Would you like to do another?: ")

    if a.lower() == 'yes':

        story_determiner(0)

    elif a.lower() == 'no':

        input("Thanks for playing! Press enter to close.")

    else:

        print("Bruh, how about you answer the question, eh?")

        repeat()

        story_determiner(0)  # This line begins the program execution

repeat()

Screenshot:

Sample run with random values:


Related Solutions

So, I have this Matlab program that I have made for a lab, and despite having...
So, I have this Matlab program that I have made for a lab, and despite having different frequencies, when I go to plot them, the graphs look exactly the same. Can someone tell me why that is? I also need to know how to determine the digital frequencies(rad/sec) and how many samples per period of both of the waves? Thank you Code: N = 100; % Total number of time domain samples in simulation. A1 = 1; % Amplitude of...
I have to do this "interview", I just need truthful/made-up answers to these questions (Include the...
I have to do this "interview", I just need truthful/made-up answers to these questions (Include the position you hold and why someone in that position can give a better feel for how someone might use accounting someday) 1. I would like to understand if and how financial reporting affects you and your work. Can you give me any examples of how accounting affects your day-to-day responsibilities or decisions? 2. What do other managers and leaders in your company use your...
I have to do this "interview", I just need truthful/made-up answers to these questions (Include the...
I have to do this "interview", I just need truthful/made-up answers to these questions (Include the position you hold and why someone in that position can give a better feel for how someone might use accounting someday) 1.      I would like to understand if and how financial reporting affects you and your work. Can you give me any examples of how accounting affects your day-to-day responsibilities or decisions? 2.      What do other managers and leaders in your company use your...
Please read the following made up story and come up with 1 1/2-2 page resolution to...
Please read the following made up story and come up with 1 1/2-2 page resolution to the story Keeping organizations properly succeeding is vital in our mission at OTC (Organizational Theory Consultants). We pride ourselves in being able to upright the most complex of situations involving various organizations needing a turn around to keep from failing in their specific industry. Organizations need to have their culture running like a well oiled machine to avoid any hiccups which can have a...
How would I create a Hangman game that chooses  a random word and the player needs to...
How would I create a Hangman game that chooses  a random word and the player needs to guess it, letter by letter using  JavaScript and jQuery to allow user interaction. The content and the style of the page must be updated based on user’s input.
C++: (I need this program to output in a certain format I will post the "needed...
C++: (I need this program to output in a certain format I will post the "needed results" below) To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letter. Write a program...
I have a group discussion about “ the first lunar landing module computer was made up...
I have a group discussion about “ the first lunar landing module computer was made up entirely of thousands of NAND gates. I need talk about this for a minute what should I say ? And I’ll talk about home security alarm how do thay work in electronic like if is the doors and windows open it will alarm a sound if thay are close it will not .
Can I have a made up data table and graph illustrating correlation and another data table...
Can I have a made up data table and graph illustrating correlation and another data table and graph illustrating regression using the similar variables? I would like to know how they differ from one another using a similar topic. Growth of birds vs food supply
In Avocado Park, 38% of the population is made up of immigrants. Consider a random sample...
In Avocado Park, 38% of the population is made up of immigrants. Consider a random sample of 78 residents of Avocado Park. a.How many individuals must reside in Avocado Park to consider the selection of these individuals to be independent? b.What is the probability that more than 30 of the residents in the sample are immigrants? c. How many immigrants should be EXPECTED to be in the sample? d.Peacoat Fashions currently employs 78 Avocado Park residents. If there are fewer...
I need to type up a story using either real life experience or simply make one...
I need to type up a story using either real life experience or simply make one up! use medical terminology in your story that tie in your tale (Examples: Pericardial, Pneumonia, and Hypothyroidism) where there is a suffix and prefix and combining forms) This assignment should be a minimum of 1 page as well as a minimum of 30 terms. Please make the 30 terms in a darker font or highlighted. Thank you in advance
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT