Support Forums

Full Version: A Magic Eight Ball, And A Guessing Game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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")
Don't worry, I thought i clicked on the pearl section.
That;s nice thanks for sharing
Very nice Big Grin
Thanks for sharing it.
Thanks for the share. Looks cool!
Thanks for the share. Nice work.
Nice with the first one, but when you start using 'for loops' you will be able to shorten the second code =P