This tutorial will show how to make a magic 8 ball program in python. This program will have the same functions as a magic 8 ball , the user will input a question and the 8-ball will generate a reply to the question.
The user’s input will by retrieved by using input() . Here is a link to a quick tutorial on the input() keyword in Python.
# Import modules
import sys
import random
reply = True #If running
while reply:
inputQuestion = input("Type 'quit' to exit... Ask magic 8 ball a question: ")
response = random.randint(1, 8)
if inputQuestion == "quit":
sys.exit() #exit program
# List of random responses
elif response == 1:
print("It is certain")
elif response == 2:
print("Don't count on it.")
elif response == 3:
print("Yes.")
elif response == 4:
print("Ask again later")
elif response == 5:
print("Concentrate and ask again")
elif response == 6:
print("Reply hazy, try again")
elif response == 7:
print("As I see it, yes.")
elif response == 8:
print("It will not be so.")
Output:
Type 'quit' to exit..Ask magic 8 ball a question: will i pass my test?
It is certain
Android Studio Loading Animation Between Activities
Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the…
Android Studio Tutorial SeekBar
SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value…
Python Ethereum Block Chain Interaction with Web3
This tutorial will show how to interact with the Ethereum blockchain using Python. To start, the Python library Web3 will need to be installed. The Web3 library allows you to interact with a local or remote Ethereum node, using a HTTP or IPC connection. Using Web3 you will be able to create smart contracts on…