This project is intended to help become more comfortable with using functions while practicing with lists, conditionals, string functions, possibly slicing, ifs and loops.
You will build a "Fortune cookie" program. For those of you not familiar with it, once upon a time there was a command line program for power users which would give a random saying printed on the command line. Often bored graduate students would sit at a terminal and keep reading these way too many times.
You will write a small simplified version of the fortune program. Your program needs to use functions
In your program you will
Create a text file in your project folder with at least 20 "quirky sayings"/fortunes (the only requirement is that they be appropriate for display in class), If I use my own file though, you should handle as many fortunes as I put in. Make each fortune its own line,
in your main function ask the user for the name of the fortunes file.
Create a load_fortunes function which
takes
the name of the fortunes file as a parameter, open that file,
read all the lines into a list of strings Create a list by reading those 20+ fortunes from your file,
then return that list from this functions
back in the main function call the display_fortunes function passing the list of strings that you got from the previous functions
the display_fortunes function should
repeat as often as the user wants:
ask the user if they want another fortune,
if the user’s answer begins with any variation in capitalization of the word ‘yes, then
select a random line from your list of fortunes and display it
if the users answer begins with no (in any capitalization) then quit the program
Don't forget to comment your program.
Your code must be commented
use functions. Something like half of the credit for this project will be assigned to using function with the right parameters and return values.
To help me identify your work, make the name of your project
yourFirstInitialLastNameProject3
(so mine would be JSantoreProject3)
And put the following at the beginning of the program as a comment:
Your name
anything that was left undone
anything that I need to know to run the program correctly.
Submit the project by putting it on github as a private project and making me a collaborator as before.