Using the script as an example and possible starting point, write a script that generates a story using multiple levels of function calls that mirror the structure of your story.

Your script must have the following requirements:

  • At least two functions must have randomly determined elements.
  • Your script must accept some form of user input (e.g. name of the hero), which is then used throughout the story.
  • The function structure of your script must have at least four levels. The example script only has three levels. To add a fourth level, you will need to define at least one extra function and have its returned result used by one of the functions at the bottom level (e.g. create_intro).
  • The script must have at least three function calls at some level in your script. The example script already meets this requirement.
  • The content of your story must be original.
  • The output of your story should be grammatically correct and neatly formatted.

Use this script and fix it with the following requirements.


# Sample story for assignment 6
import random

def create_whole_story(hero_name):
intro = create_intro(hero_name)
conflict = create_conflict(hero_name)
resolution = create_resolution(hero_name)
return intro + conflict + resolution

def create_intro(hero):
return hero + ” lived in a land not too far away.n”

def create_conflict(hero):
demise = random.choice([“ring of fire”, “tarry pit”, “dark abyss”])
return “Alas! {} fell into a {}.n”.format(hero, demise)

def create_resolution(name):
fate = random.choice([“lives”, “dies”])
if fate == “lives”:
return “Fortunately, wandering shepards came by and saved {}.”.format(name)
return “Sadly, that was the last we saw of {}.”.format(name)

hero = input(“What is the hero’s name? “)

print(“Here’s your story…”)