Question

In this module you learned about arrays. You also began learning about implementing arrays and how...

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.

  • You will need put the sayings into an array(No Files at this point).
  • The game should allow the the player to ask/type in a question.
  • One of the sayings should be randomly picked from the array and displayed to the player(Hint: use random.choice - see link).
  • Write the pseudocode and Flowchart for a program that simulates the Magic eight ball game.
  • Make a working version of this program in Python.

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!"
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In order to answer this you need to know the following in python:

  • How make an array?

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)

  • How to take input from user?

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.")

  • random.choice() function

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)

  • print() function

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 ??

Add a comment
Know the answer?
Add Answer to:
In this module you learned about arrays. You also began learning about implementing arrays and how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this module you learned about File Handling. You began learning about how data can be...

    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...

    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...

    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...

  • Have you ever wanted to predict the future? Well the Magic Eight Ball does just that....

    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...

    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)....

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    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...

    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...

  • #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate...

    #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate a random number. Then it has to declare how many tries the user has for the game loop. we then need the player to enter their guess. After every guess we have to give an output of how many numbers they have in the right location and how many they have the right number. The player will keep guessing until their 10 tries are...

  • in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and...

    in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and follow the directions below carefully and perform the steps in the order listed. You will be solving one program as instructed and turning in your work electronically via an uploaded file within Eagle Online/Canvas and copy & paste the program to the Text Entry box as well. Make sure and check your work prior to uploading the assignment (NOTE: For Steps 1 & 2...

  • 6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you...

    6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT