Question
PROGRAM IN PYTHON ONLY Write a program that will randomly generate a fortune for its user based on their age. The fortune teller asks for
PROGRAM IN PYTHON ONLY
Write a program that will randomly generate a fortune for its user based on their age. The fortune teller asks for their birthday in the form of mmddyyyy, anyone under 21 gets a PG fortune and anyone over 21 gets a PG-21 fortune.
Your program should have seven functions:
main(): The driver function. User input is received, the other functions are called and the final output message is displayed.
getAge(): Calculates and returns the users age using the input
getZodiac(): Returns a string with the user's zodiac sign
sentence1(): Determines the first sentence of the fortune
sentence2(): Determines the second sentence of the fortune
sentence3(): Determines the third sentence of the fortune
sentence4(): Determines the fourth sentence of the fortune
Here is an example of sample input/output:
What's your name? Sheila
What is your dob? mmddyyyy 10021982
Hello Sheila.
Oh you are a(n) Libra!
My crystal ball is telling me...
A Morehouse man with a Porsche needs your help hiding a body. You better jump on the opportunity!
Take care with your fortune!
Would you like to have another fortune told? Y or N
The program works as follows: each fortune consists of at least 4 sentences, with a fixed grammatical structure. Therefore, it is easy to randomly replace any of the 4 sentences and still create a grammatically correct story. The 4 sentences have the following structure:
Sentence 1: Creates a subject (person or thing)
Sentence 2: Describes the subject
Sentence 3: Predicts an action by the subject
Sentence 4: Offers the user some advice
An example fortune might read like this:
If the fortune seeker is under 21:
Sentence 1: A friend from school
Sentence 2: who has really bad breath,
Sentence 3: wants to friend you on Facebook
Sentence 4: Better run the other way!
If the fortune seeker is over 21:
Sentence 1: A Morehouse man from France
Sentence 2: with a bald head,
Sentence 3: seeks your hand in marriage
Sentence 4: Beware of wolves in sheeps clothing!
Sample sentences:
Sentence 1
(sentence1() randomly prints one of these 4 sentences)
A Morehouse man
A flamboyant old woman
A tall, dark and handsome supermodel
A nutty professor
Sentence 2
(sentence2() randomly prints one of these 4 sentences)
with a wart on his nose
carrying a dog
missing a few teeth
dressed to impress
Sentence 3
(sentence3() randomly prints one of these 4 sentences)
will ask you to dance.
will offer you a hamburger.
wants to be your friend.
will take all your money.
Sentence 4
(sentence4() randomly prints one of these 4 sentences)
But don't worry about it.
Try not to lose any sleep over it.
This could be your lucky day!
Just tell him what you think.
Obviously, there is no reason to limit the number of sentences to 4. Makeup 4 of your own creative phrases to add to the list above. Each sentence should have 8 choices.
Randomizing the choices:
In order to create a random selection from the list you will need to import the random module by including the following code at the top of your program:
from random import choice
An example of how this is implemented to pick a die toss from a container:
toss = choice([1, 2, 3, 4, 5, 6])
Importing todays date:
Instead of having the user enter todays date. We will utilize a module to give us the current system date from the computer. In order to do this you must import a module called datetime by typing the following at the top of your program:
from datetime import date
To save todays date as a string variable you will use the code:
today = str(date.today())#yyyy-mm-dd (ie. 2018-10-15)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started