Support Forums
A Magic Eight Ball, And A Guessing Game - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32)
+---- Thread: A Magic Eight Ball, And A Guessing Game (/showthread.php?tid=1268)



A Magic Eight Ball, And A Guessing Game - nevets04 - 10-11-2009

Magic 8 ball

Code:
import os
os.system("clear")
loop = 1
while loop == 1:
    import random
    raw_input("Ask your question: ")
    a = ["Yes","No","Ask Again Later","Go die","Maybe"]
    p = random.choice(a)
    print(p)

Guessing Game

Code:
import random
import os
os.system("clear")
a = 0
g = 0
l = 1
b = ["1","2","3","4","5","6","7","8","9","10"]
c = random.choice(b)
while l == 1:
    os.system("clear")
    print "1) Single Player"
    print "2) Two Players"
    a = input("Chooce Amount Of Players: ")
    os.system("clear")
    if a == 1:
        d = raw_input("Guess A Number Between One And Ten: ")
        os.system("clear")
        if c == d:
            print "You Win!"
        elif c != d:
            print "You Lose..."
    
    if a == 2:
        e = raw_input("Player 1, Choose A Number Between One And Ten: ")
        os.system("clear")
        f = raw_input("Player 2, Guess A Number Between One And Ten: ")
        os.system("clear")
        if f == e:
            print("Player 2 Wins!")
        elif f != e:
            print("Player 1 Wins!")
    print "1) Play Again"
    print "2) Exit"
    g = input("Make Your Decision: ")
    if g == 1:
        l = 1
    if g == 2:
        l = 0
        os.system("clear")



RE: A Magic Eight Ball, And A Guessing Game - Extasey - 10-12-2009

Don't worry, I thought i clicked on the pearl section.


RE: A Magic Eight Ball, And A Guessing Game - Akshay* - 10-12-2009

That;s nice thanks for sharing


RE: A Magic Eight Ball, And A Guessing Game - Don Panzer - 04-11-2010

Very nice Big Grin
Thanks for sharing it.


RE: A Magic Eight Ball, And A Guessing Game - alfonzo1955 - 06-17-2010

Thanks for the share. Looks cool!


RE: A Magic Eight Ball, And A Guessing Game - Crysis. - 06-17-2010

Thanks for the share. Nice work.


RE: A Magic Eight Ball, And A Guessing Game - xerotic - 08-13-2010

Nice with the first one, but when you start using 'for loops' you will be able to shorten the second code =P