8 Ball Fortune Try Again Later

Python Projects: Magic 8 Brawl for fortune-telling or seeking advice

Python Project-v with Solution

Create a Python projection of a Magic eight Ball which is a toy used for fortune-telling or seeking advice.

Note :

  • Permit the user to input their question.
  • Show an in progress bulletin.
  • Create 10/20 responses, and show a random response.
  • Allow the user to ask another question/advice or quit the game.

Sample Solution -1 :

Python Code:

          #Make a Magic 8 ball #https://github.com/viljow/magic8/blob/master/main.py import random answers = ['It is certain', 'It is decidedly so', 'Without a uncertainty', 'Yep – definitely', 'You lot may rely on it', 'Every bit I see it, yes', 'Most likely', 'Outlook good', 'Yes Signs point to yes', 'Respond hazy', 'attempt again', 'Enquire again later', 'Better not tell you lot now', 'Cannot predict now', 'Concentrate and ask again', 'Dont count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very hundred-to-one']  print('  __  __          _____ _____ _____    ___  ') print(' |  \/  |   /\   / ____|_   _/ ____|  / _ \ ') print(' | \  / |  /  \ | |  __  | || |      | (_) |') print(' | |\/| | / /\ \| | |_ | | || |       > _ < ') print(' | |  | |/ ____ \ |__| |_| || |____  | (_) |') print(' |_|  |_/_/    \_\_____|_____\_____|  \___/ ') impress('') print('') print('') impress('Hullo Earth, I am the Magic 8 Ball, What is your proper noun?') proper name = input() impress('hello ' + name)   def Magic8Ball():     print('Ask me a question.')     input()     print (answers[random.randint(0, len(answers)-1)] )     print('I hope that helped!')     Replay()       def Replay():     print ('Do you have another question? [Y/Due north] ')     reply = input()     if answer == 'Y':         Magic8Ball()     elif reply == 'Due north':         exit()     else:         print('I apologies, I did not take hold of that. Please repeat.')         Replay()  		 Magic8Ball()                  

Output:

          __  __          _____ _____ _____    ___    |  \/  |   /\   / ____|_   _/ ____|  / _ \   | \  / |  /  \ | |  __  | || |      | (_) |  | |\/| | / /\ \| | |_ | | || |       > _ <   | |  | |/ ____ \ |__| |_| || |____  | (_) |  |_|  |_/_/    \_\_____|_____\_____|  \___/     Hello World, I am the Magic 8 Ball, What is your name? Sara hello Sara Ask me a question. Tell my fortune Information technology is sure I hope that helped! Do you lot have another question? [Y/N]  Y Ask me a question. My favorite color My reply is no I hope that helped! Do you have another question? [Y/North]  N        

Flowchart:

Python Flowchart: Magic 8 Ball-1

Sample Solution -2 :

Python Code:

          #https://github.com/soupyck/Magic8Ball/blob/chief/magic8ball.py import random import time  eight_ball = [ "It is certain", "It is decidedly then", "Without a doubt", "Yes, definitely",                "You may rely on it", "As I meet it, yes", "Almost Likely", "Outlook Good",                "Yes", "Signs betoken to yes", "Answer hazy, try over again", "Inquire over 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 non so skilful", "Very Doubtful"]  def question():     question = input("You may inquire your yep or no question of the Magic 8 Ball!\n")     print("Thinking...")     time.sleep(random.randrange(0,v))     impress(random.choice(eight_ball))  while True:     question()     repeat = input("Would y'all similar to ask another question? (Y or North)")     if non (repeat == "y" or repeat == "Y"):         print("Come back if y'all have more than questions!")         break                  

Sample Output:

You may ask your yep or no question of the Magic 8 Ball! Tell me my fortune Thinking... Yous may rely on it Would you similar to ask some other question? (Y or Due north)Y You lot may ask your yes or no question of the Magic eight Ball! yeah Thinking... Yep, definitely Would you like to ask another question? (Y or N)northward Come back if you accept more questions!        

Flowchart:

Python Flowchart: Magic 8 Ball-2

Sample Solution -3 :

99 bottles of beer...

Python Lawmaking:

          https://github.com/pixelnull/8ball/hulk/chief/8ball.py import random import time  # Set count to how many times user wants to do the magic 8ball count_str = input("Hello user. How many questions would you like to enquire the viii-Ball? ")  # Handling if count_str is non a number while Truthful:     if count_str.isdigit():         count = int(count_str)         break     else:         count_str = input("You cheeky devil, just enter a uncomplicated number this time: ")  # Outlier input handling if count <= 0:     impress("Well I didn't want to play with you either!")     time.slumber(five)     exit() elif count > 10:     print("\nYou accept to be kidding me, you desire to practise that many questions?\nWe'll do one and go from there.\n", sep='')     count = 1  # Sequence for random.pick answers = ["It is certain.", "Information technology is decidedly so.", "Without a doubt", "Aye definitely.", "You may rely on it.",            "As I see it, yes.", "Most probable.", "Outlook expert.", "Aye.", "Signs bespeak to yeah.", "Answer hazy try again.",            "Enquire again later.", "Better not tell y'all now.", "Cannot predict now.", "Concentrate and ask over again.",            "Don\'t count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."]  # Main loop and graceful leave while count > 0:     blah = input("Blazon your question: ")     dice = random.option(answers)     impress("\north", dice, "\n", sep='')     time.slumber(2)     count = count - 1 else:     print("\nI promise you liked the respond(s). THE Bang-up 8-Brawl HAS SPOKEN!")     fourth dimension.sleep(5)     exit()                  

Sample Output:

Hello user. How many questions would yous similar to ask the eight-Ball? 1 Type your question: Tell me my fortune  Signs point to aye.   I hope yous liked the answer(southward). THE GREAT 8-BALL HAS SPOKEN!        

Flowchart:

Python Flowchart: Magic 8 Ball-3

Sample Solution -4 :

Python Code:

          #https://github.com/DeronKHolmes/magic-8-ball-game/blob/master/eightball.py import random import time, sys play_again = 'yes'  while play_again == 'yeah':     str(input("Welcome to the Magic 8-Ball. Enter your question: ")).lower()          #Delay output for 1 2nd each     print("Thinking...")     time.sleep(ane)     print("3...")     time.sleep(1)     impress("2...")     fourth dimension.sleep(i)     print("1...")     time.slumber(one)     impress()          #Generate a random integer/response     response = random.randint(0,20)          if response == 1:         impress("Not merely no, hell no!")     elif response == 2:         print("Sure matter.")     elif response == 3:         impress("Don't count on it.")     elif response == 4:         impress("Maybe not.")     elif response == 5:         print("Count on it.")     elif response == six:         print("The Universe says perchance.")     elif response == 7:         print("I don't see why not.")     elif response == viii:         impress("The future looks good for you.")     elif response == nine:         print("That's for certain.")     elif response == 10:         print("Maybe.")     elif response == eleven:         print("There's a chance.")     elif response == 12:         impress("Certainly!")     elif response == 13:         print("Keep doing what you're doing and it'll happen.")     elif response == 14:         print("Not over my dead 8 Brawl.")     elif response == 15:         print("No.")     elif response == 16:         print("Yes.")     elif response == 17:         print("All depends on if you've been expert for Santa this year.")     elif response == 18:         print("Not in this lifetime.")     elif response == xix:         impress("Someday, simply not today.")     elif response == 20:         print("Right after y'all hitting the lottery.")     else:         impress("Not a valid question!")      play_again = str(input("Would you like to inquire another question? yes/no ")).lower()     if play_again == 'no':         impress("Goodbye! Thanks for playing!")         sys.exit()                  

Sample Output:

Welcome to the Magic viii-Ball. Enter your question: Tell me my fortune Thinking... three... 2... 1...  Mayhap not. Would you lot similar to ask another question? yes/no yep Welcome to the Magic 8-Ball. Enter your question: My favorite color Thinking... 3... 2... one...  No. Would y'all like to inquire another question? yep/no no Adieu! Cheers for playing!        

Flowchart:

Python Flowchart: Magic 8 Ball-4

Contribute your lawmaking and comments through Disqus.

greenearehiscied.blogspot.com

Source: https://www.w3resource.com/projects/python/python-projects-5.php

0 Response to "8 Ball Fortune Try Again Later"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel