Welcome back to another video! In this video, You will get source code for mini python projects for beginners.
Here is simple game of Rock Paper Scissor of Player against the Computer.
User selects one of the three options from Rock, Paper or Scissor and Computer selects a random option.
Test your skills and strategy to win against the computer. It's really fun to play and you can play as many times as you want.
You will learn to create a game from scratch. Using this template, you can keep building and practicing your programming skills.
Here is the full python source code of the famous game below...
-- Source Code Begin : RockPaperScissor.py --
import random
cont = True
hands = {1: "Rock", 2: "Paper", 3: "Scissor"}
beats = {1: [3], 2: [1], 3: [2]}
score = {"User": 0, "Comp": 0}
while cont:
print("Select any one...")
for a in hands.items():
print(f"{a[0]}. {a[1]}")
choice = input("What is your choice ? ")
if not choice.isdigit():
choice = 0
user = int(choice)
if user not in hands.keys():
print("Sorry, wrong choice !!!")
continue
comp = random.randint(1, 3)
print(f"You selected {hands[user]}, Computer selected {hands[comp]}")
defeat = beats[user]
if user == comp:
print(f"Both selected {hands[user]}. It's a draw !!!")
elif comp in defeat:
print(f"{hands[user]} beats {hands[comp]}. You WIN !!!")
score["User"] = score["User"] + 1
else:
print(f"{hands[comp]} beats {hands[user]}. You LOSE !!!")
score["Comp"] = score["Comp"] + 1
print(f"Scores: You = {score['User']} | Comp = {score['Comp']}")
play_again = input("Press enter to play again ! Anything else to quit ? ")
if play_again != '':
cont = False
print("Hope you enjoyed the game! See you soon...")
-- Source Code End --
#PythonProjects #beginner #pythonforbeginner #miniproject
#shorts #project #sourcecode #pythonsourcecode #python #programming #coding #youtubechannel #youtube #youtuber