Python Project – Rock, Scissor, Paper Game
Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
# Rock Scissors and Paper Game
import random
#function for computer choice
def get_comp_choice():
return(random.choice(['rock','paper','scissors']))
#function for user choice
def get_user_choice():
choice=input("Enter your choice between('rock','paper','scissors')").lower()
while choice not in('rock','paper','scissors'):
print("Invalid choice please enter('rock','paper','scissors')")
choice=input("Enter your choice between('rock','paper','scissors')").lower()
return choice
#function for decalre winner
def declare_winner(userchoice,compchoice):
if(userchoice==compchoice):
return " Its a tie !"
else:
if((userchoice=='rock' and compchoice=='scissors') or (userchoice=='scissors' and compchoice=='paper') or (userchoice=='paper' and compchoice=='rock')):
return " You are Winner !"
else:
return " Computer is a Winner !"
#Main Method
while(True):
print("---------Rock Scissors and Paper Game---------")
user_choice=get_user_choice()
comp_choice=get_comp_choice()
print("{User Choice is: }",user_choice)
print("{Computer Choice is: }",comp_choice)
print(declare_winner(user_choice,comp_choice))
user_choice=input("Want to play more(yes/no)").lower()
if(user_choice=='no'):
break
print("Ok Good Bye.......!")
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

