In this module you learned about arrays. You also began learning about implementing arrays and how they can help organize the data in a program.
The magic ball eight was created in the 50's and was produced by mattel. Eight Ball is a toy and is just a game. The magic 8 ball answers your yes/no questions. You will be creating a version of the Magic 8 Ball game. You can use whats inside the attached file to build your array of sayings or use your own.
Complete the flowchart and pseudocode using draw.io. Include your pseudocode by adding a “square shape” next to your flowchart and populating it with your pseudocode for the program. Export your work in PDF format and upload it to the Blackboard assignment area by clicking on the Browse My Computer button below the text editor.
Complete the Python code using IDLE. Upload your .py file to the Blackboard assignment area by clicking on the Browse My Computer button below the text editor.
This assignment is worth 20 points and will be evaluated using the objectives of the assignment listed.
EightBData.txt
"As I see it, yes" "It is certain" "Most likely" "Outlook good" "Without a doubt" "Yes - definitely" "You may rely on it" "Reply hazy, try again" "Ask again later" "Better not tell you now" "Cannot predict now" "Concentrate and ask again" "Don't count on it" "My reply is no" "My sources say no" "Outlook not so good" "Very doubtful" "Do I Look Like I Care?" "Yeah, Right" "Ask Again Later" "DUH!"
In order to answer this you need to know the following in python:
In python we create an array by arr = [1, 2, 3, 4, 5]. arr is the name of the array chosen by the user and it stores the values 1 to 5. The values need to be comma separated and can be accessed by the using the index after the array name( arr[2] stores the value 3, arr[0] stores the value 1)
To take an input from the user we choose a name for the variable which would store the input and then use the input() function to store it.
name_of_input_variable = input("Prompt user for input.")
To use the random.choice() function we first have to import the random library which contains the function. To import the random library into python we use,
import random
We can then use the random.choice() function which would take as input the any array and return a random choice from the values stored in the array. We need to use a variable to store the value returned by the random.choice() function.
value_returned = random.choice(name_of_array)
The print() function is used to print some value to the console. We can print variables which store some value.
a=3
print(a)
print(a) will print the value 3. If we want to print the alphabet a we put it withing double quotes.
print("a")
Flowchart

Python Code
array = ["As I see it, yes", "It is certain", "Most likely", "Outlook good", "Without a doubt", "Yes - definitely", "You may rely on it", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful", "Do I Look Like I Care?", "Yeah, Right", "Ask Again Later", "DUH!" ]
question = input("Enter your question: ")
import random
answer = random.choice(array)
print(answer)

Note: Ususally the import random(or any import) are done at the beginning of the file to make things look neat and clean. However here for the sake of understanding I put it right before the random.choice() is used.
Hope this may help you
Thank you ??
In this module you learned about arrays. You also began learning about implementing arrays and how...
In this module you learned about File Handling. You began learning about how data can be imported into, manipulated in, and exported from a program. Alter the assignment from Ch6 (Magic 8 Ball Game) so that it reads the Magic 8 Ball game sayings from a file and loads them into an array. The rest of the program should be the same. Previous Game: "The magic ball eight was created in the 50's and was produced by mattel. Eight Ball...
In this module, you learned about Arrays in C++ and how to implement arrays within your C++ programs. For this assignment, you will implement your knowledge of arrays for Michigan Popcorn Company’s sales management system. Write a program that lets the Michigan Popcorn Company keep track of their sales for seven different types of popcorn they produce: plain, butter, caramel, cheese, chocolate, turtle and zebra. It should use two parallel seven-element arrays: an array of strings that holds the seven...
Using python The following is a modified version of the magic 8 ball. We have 20 mysterious answers to questions about anything in the universe. Each time we start this program by randomly picking 8 answers and then we randomly pick 1 from these 8 answers. This lucky answer will then be printed. This time we use the sample() function from the random library. This function randomly samples a list and return the random samples in a list. import random...
PROMT: Step 1 - Reading the code This is one of the few labs you will only have to write a single method. While you are free to write more methods (hint: it may be easier with more), you are not required to write more. Before you start, take a moment to read the code provided. You will notice that the method missing is: public static String getAnswer(int category, int answer). This is the method you will write. For reference,...
Have you ever wanted to predict the future? Well the Magic Eight Ball does just that. The original game was a softball sized “8-ball”. You would ask a question, shake it up and look at the result. There are 20 responses…10 positive, 5 negative, and 5 are vague. For this project, we want to recreate this, but give the ability to read in a set of responses, and add additional responses, and print out all of the responses in alphabetical...
Lab #7 CSE110 - Arizona State University Topics • Basic arrays Coding Guidelines • Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). • Keep identifiers to a reasonably short length. • Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects). • Use tabs or spaces to indent code within blocks (code surrounded by braces)....
CMPS 290 Programming Assignment Arrays and Recursion – Fibonacci Numbers In this programming assignment you will be working with arrays and multiple function calls, including a recursive function call. The goal of the assignment will be to, using a pre-set array of sequence numbers, calculate the Fibonacci sequence number for each value in the array (see the example at the bottom if this isn’t clear). Instructions and Requirements: • Create a program that assembles and runs to find the correct...
Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...
Use basic java for this after importing PrintWriter object You will make a simple Magic Square program for this Java Programming Assignment. Carefully read all the instructions before beginning to code. It is also required to turn in your pseudocode or a flowchart along with this program. Here are the instructions: At the beginning of the program, briefly describe to the user what a Magic Square Matrix is (described further on), and then allow them to enter “start” to begin...
In this module you learned about Object-Oriented programming in C++ and how to combine this approach with the concepts covered in previous modules For this assignment you will write a class called Dog that has the following member variables: birthyear. An int that holds the dog’s birth year. breed. A string that holds the breed of dog. vaccines. A Boolean holding a yes/no value indicating whether the dog is currently on vaccinations. In addition, the class should have the following...