An easy way [for beginners] codehs rocks, paper and scissors
Long because its for beginners if u are advanced use the above code..
"""
Introduction - Imports, Instructions, Declaring Variables, Lists and Computer Choice
"""
# Imports
import time
time.sleep(2)
print "Hello !"
# Delays Response to 2 secs
time.sleep(2)
# Instructions
print "Are you ready to play Rock, Paper and Scissors with the Computer ? "
time.sleep(4)
# Asking if user is ready or not !! (Does Nothing whatever the User Answers)
yes_no = input("Are You Ready to play (Y/N) : ")
time.sleep(2)
print "Ready or Not, here we go !! "
time.sleep(2)
# Declaring Variables
win_user = 0
win_comp = 0
tie = 0
# Imports Random and Sys
import random
import sys
# Choices in a list
choices = ["Rock", "Paper", "Scissors"]
# Computer Choice - between choices [list]
comp_choice = random.choice(choices)
"""
User Input and Computer Input
"""
# Asks User for Rocks, Papers or Scissors
user_input = input("Rock, Paper or Scissors ? : ")
# User_input is now set to User_choice
user_choice = user_input
time.sleep(2)
# Prints what user entered
print "User entered : " + user_choice
time.sleep(2)
# Prints what computer entered
print "Computer entered : " + comp_choice
# Basic Gameplay
if user_choice == "Rock" and comp_choice == "Paper":
win_comp += 1
if user_choice == "Paper" and comp_choice == "Rock":
win_user += 1
if user_choice == "Scissors" and comp_choice == "Paper":
win_user += 1
if user_choice == "Paper" and comp_choice == "Scissors":
win_comp +=1
if user_choice == "Rock" and comp_choice == "Scissors":
win_user +=1
if user_choice == "Scissors" and comp_choice == "Rock":
win_comp +=1
if user_choice == "Rock" and comp_choice == "Rock":
tie +=1
if user_choice == "Paper" and comp_choice == "Paper":
tie +=1
if user_choice == "Scissors" and comp_choice == "Scissors":
tie +=1
"""
Ties, User Wins and Computer Wins and Conclusion
"""
time.sleep(2)
# Checks the amounts of ties, user wins and computer wins !!!
print "User Wins : " + str(win_user)
time.sleep(2)
print "Computer Wins : " + str(win_comp)
time.sleep(2)
print "Ties : " + str(tie)
time.sleep(2)
print "Thank You For Playing !!"
"""
Exit and Repeats
"""
time.sleep(2)
# Asks if User wants to exit or Not !!
ask_user = input("Do you want to exit (Y/N) : ")
# Exit is a variable which does nothing thus it exits the game
exit = 0
# If Y, then it will exit
if ask_user == "Y":
# Does nothing, except adding a 1 to exit
exit += 1
# Elif ask_user == "N", repeats everything again using the WHile loop
elif ask_user == "N":
# WHILE LOOP
while ask_user == "N":
win_user = 0
win_comp = 0
tie = 0
import time
import random
import sys
choices = ["Rock", "Paper", "Scissors"]
comp_choice = random.choice(choices)
time.sleep(2)
user_input = input("Rock, Papers or Scissors ? : ")
user_choice = user_input
time.sleep(2)
print "User entered : " + user_choice
time.sleep(2)
print "Computer entered : " + comp_choice
if user_choice == "Rock" and comp_choice == "Paper":
win_comp += 1
if user_choice == "Paper" and comp_choice == "Rock":
win_user += 1
if user_choice == "Scissors" and comp_choice == "Paper":
win_user += 1
if user_choice == "Paper" and comp_choice == "Scissors":
win_comp +=1
if user_choice == "Rock" and comp_choice == "Scissors":
win_user +=1
if user_choice == "Scissors" and comp_choice == "Rock":
win_comp +=1
if user_choice == "Rock" and comp_choice == "Rock":
tie +=1
if user_choice == "Paper" and comp_choice == "Paper":
tie +=1
if user_choice == "Scissors" and comp_choice == "Scissors":
tie +=1
time.sleep(2)
print "User Wins : " + str(win_user)
time.sleep(2)
print "Computer Wins : " + str(win_comp)
time.sleep(2)
print "Ties : " + str(tie)
time.sleep(2)
print "Thank You For Playing !!"
time.sleep(2)
ask_user = input("Do you want to exit (Y/N) : ")
if ask_user == "Y" or "Yes" or "y" or "yes":
break
else:
print "Wrong Input, Try again by restarting the program"