These are the original instructions:
"Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question and then display the answer as long as the user wishes to continue.

Store eight Magic Eight Ball answers in an array. For every question that a user asks, an answer should be randomly selected from the list of answers. You are free to make up any answers you wish.

Your program must contain 4 functions that are all called from the main program. One to create and return the list of answers, one to get and return the user's question, one to generate and return a random number, and one to print the Magic Eight Ball answer."

I'm very new to the programming world and have had quite some trouble figuring out all the concepts, especially calling and returning functions.


Can anyone help?
This is what i have so far below

#Sam McDonnell
#Lab 8-1
#This program uses arrays and the randint function to emulate a magic 8-ball

import random 

#create an array of 8 elements
eightBall = [0, 1, 2, 3, 4, 5, 6, 7]

#function definitions

#this function creates the list of answers


#this function asks for users question and returns it


#this function generates and returns a random number

def shakeBall():
    shake = random.randint(eightBall)
    return shake

#this function prints the magic 8-ball answer


eightBall[0] = print “Can't tell you now”
eightBall[1] = print “It is certain”
eightBall[2] = print “Ask again later”
eightBall[3] = print “Yes”
eightBall[4] = print "Don’t count on it”, 
eightBall[5] = print “My source says No”
eightBall[6] = print “Very doubtful” 
eightBall[7] = print “Maybe”

#main program
print "Welcome to the magic 8-ball game!"
print "Type a yes or no question to play, or type 'exit' to quit."
while eightBall != (0,8):
    print "Thank you for playing"
print "\nShaking the Ball. . . . "
eightBall = shakeBall() 
print eightBall

I like this explanation of the parts of a function http://www.tutorialspoint.com/python/python_functions.htm. Tutorials are there for a reason, i.e they can be written once and read many times by many people. Start a list of good tutorials so you don't have to post to a forum with questions about very basic concepts that are covered in virtually every tutorial.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.