Professional Documents
Culture Documents
Magic 8 Ball Advanced Task
Magic 8 Ball Advanced Task
It is not efficient to store big long lists in a program. Instead we use files. Try out the program below.
1) Open Notepad and enter the list of responses below. Save it in your My Documents as “magic8”
It is certain
It is decidedly so
Without a doubt
Yes definitely
You may rely on it
As I see it, yes
Most likely
Outlook good
Yes
Signs point to yes
f = open(‘n:\magic8.txt','r')
responses = f.readlines()
time.sleep(2)
print(random.choice(responses))
3) Fully comment your code in Python to make sure you understand what it does.
4) Add more lines to your magic8 text file. Test your program.