Skip to main content

Stone, Paper and Scissor - Game (only code)

 

This Project is of a Game, which is very popular among small children.
I have made it using Python. We can play it with Computer.

HOW TO RUN THIS CODE:-

Download any python running IDE to run this code.

HERE's THE CODE:-

import random

habby = ["Stone" , "Paper" , "Scissor"]

riu = random.choice(habby)

humanr = 0

computer = 0

print("\t\tWELCOME TO STONE, PAPER AND SCISSOR GAME.")

print("\t\tTHIS GAME IS BETWEEN YOU AND COMPUTER.\n")

i = 1

while (i<=10) :

    null = input("ENTER 'st' FOR STONE, 'p' FOR PAPER AND 's' FOR SCISSOR.\n==> ")

    if(riu=="Stone" and null=="p") :

        print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

        humanr = humanr+1

        print(f"YOUR TOTAL POINTS = {humanr}")

    elif(riu=="Stone" and null=="st") :

        print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

    elif(riu=="Stone" and null=="s") :

        print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

        computer = computer+1

        print(f"COMPUTER's TOTAL = {computer}")

    elif(riu=="Paper" and null=="p") :

        print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

    elif(riu=="Paper" and null=="st") :

        print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

        computer = computer+1

        print(f"COMPUTER's TOTAL = {computer}")

    elif(riu=="Paper" and null=="s") :

        print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

        humanr = humanr+1

        print(f"YOUR TOTAL POINTS = {humanr}")

    elif(riu=="Scissor" and null=="s") :

        print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

    elif(riu=="Scissor" and null=="st") :

        print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

        humanr = humanr+1

        print(f"YOUR TOTAL POINTS = {humanr}")

    elif(riu=="Scissor" and null=="p") :

        print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

        computer = computer+1

        print(f"COMPUTER's TOTAL = {computer}")

    else :

        print("THERE IS SOME ERROR IN TYPING." , f"                                        REMAINING ROUNDS = {10-i}")

    riu = random.choice(habby)

    i+=1

if(humanr>computer) :

    print("\n\t\tYOU ARE THE WINNER OF THIS GAME.")

    print(f"\t\tNUMBER OF ROUNDS YOU WON = {humanr}")

elif(humanr==computer) :

    print("\n\t\tTHE GAME IS TIED.")

    print(f"\t\tBOTH WON = {computer} ROUNDS")

elif(humanr<computer) :

    print("\n\t\tCOMPUTER IS THE WINNER OF THIS GAME.")

    print(f"\t\tNUMBER OF ROUNDS HE WON = {computer}")


def repeatr() :

    humanr = 0

    computer = 0

    print("\t\tWELCOME TO STONE, PAPER AND SCISSOR GAME.")

    print("\t\tTHIS GAME IS BETWEEN YOU AND COMPUTER.\n")

    i = 1

    riu = random.choice(habby)

    while (i<=10) :

        null = input("ENTER 'st' FOR STONE, 'p' FOR PAPER AND 's' FOR SCISSOR.\n==> ")

        if(riu=="Stone" and null=="p") :

            print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

            humanr = humanr+1

            print(f"YOUR TOTAL POINTS = {humanr}")

        elif(riu=="Stone" and null=="st") :

            print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

        elif(riu=="Stone" and null=="s") :

            print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

            computer = computer+1

            print(f"COMPUTER's TOTAL = {computer}")

        elif(riu=="Paper" and null=="p") :

            print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

        elif(riu=="Paper" and null=="st") :

            print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

            computer = computer+1

            print(f"COMPUTER's TOTAL = {computer}")

        elif(riu=="Paper" and null=="s") :

            print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

            humanr = humanr+1

            print(f"YOUR TOTAL POINTS = {humanr}")

        elif(riu=="Scissor" and null=="s") :

            print("THIS IS A TIE." , f"                                                        REMAINING ROUNDS = {10-i}")

        elif(riu=="Scissor" and null=="st") :

            print("YOU WON THIS ROUND." , f"                                                   REMAINING ROUNDS = {10-i}")

            humanr = humanr+1

            print(f"YOUR TOTAL POINTS = {humanr}")

        elif(riu=="Scissor" and null=="p") :

            print("COMPUTER WON THIS ROUND." , f"                                              REMAINING ROUNDS = {10-i}")

            computer = computer+1

            print(f"COMPUTER's TOTAL = {computer}")

        else :

            print("THERE IS SOME ERROR IN TYPING." , f"                                        REMAINING ROUNDS = {10-i}")

        riu = random.choice(habby)

        i+=1

    if(humanr>computer) :

        print("\n\t\tYOU ARE THE WINNER OF THIS GAME.")

        print(f"\t\tNUMBER OF ROUNDS YOU WON = {humanr}")

    elif(humanr==computer) :

        print("\n\t\tTHE GAME IS TIED.")

        print(f"\t\tBOTH WON = {computer} ROUNDS")

    elif(humanr<computer) :

        print("\n\t\tCOMPUTER IS THE WINNER OF THIS GAME.")

        print(f"\t\tNUMBER OF ROUNDS HE WON = {computer}")

hobbie = input("IF YOU WANT TO CONTINUE THEN PRESS 'y' OTHERWISE PRESS ANYTHING TO LEAVE.\n==> ")

if(hobbie!="y") :

    print("THANKS FOR PLAYING MY GAME.")

while(hobbie=="y") :

    repeatr()

    hobbie = input("IF YOU WANT TO CONTINUE THEN PRESS 'y' OTHERWISE PRESS ANYTHING TO LEAVE.\n==> ")

    if(hobbie!="y") :

        print("THANKS FOR PLAYING MY GAME.")

    continue


Comments

Popular posts from this blog

Python Bill Generator (only code)

SPACE WAR - GAME