Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions BrowserHistory/rock_paper_scissors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
Rock, Paper, Scissors Game (CLI Version)
Author: Your Name
"""

import random


def get_user_choice():
"""Prompt the user to enter their choice."""
choice = input("Enter your choice (rock, paper, scissors): ").lower()
if choice in ["rock", "paper", "scissors"]:
return choice
else:
print("Invalid choice! Please enter rock, paper, or scissors.")
return get_user_choice()


def get_computer_choice():
"""Randomly select computer's choice."""
options = ["rock", "paper", "scissors"]
return random.choice(options)


def decide_winner(player, computer):
"""Decide the winner based on the choices."""
if player == computer:
return "It's a draw!"
elif (
(player == "rock" and computer == "scissors")
or (player == "paper" and computer == "rock")
or (player == "scissors" and computer == "paper")
):
return "You win!"
else:
return "Computer wins!"


def main():
"""Main function to play the game."""
user_choice = get_user_choice()
computer_choice = get_computer_choice()
print(f"Computer chose: {computer_choice}")
print(decide_winner(user_choice, computer_choice))


if __name__ == "__main__":
main()
52 changes: 0 additions & 52 deletions rock_paper_scissor_game.py

This file was deleted.

48 changes: 48 additions & 0 deletions rock_paper_scissors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
Rock, Paper, Scissors Game
Author: DEVANSH-GAJJAR
"""

import random


def get_user_choice():
"""Prompt the user to enter their choice."""
choice = input("Enter your choice (rock, paper, scissors): ").lower()
if choice in ["rock", "paper", "scissors"]:
return choice
else:
print("Invalid choice! Please enter rock, paper, or scissors.")
return get_user_choice()


def get_computer_choice():
"""Randomly select computer's choice."""
options = ["rock", "paper", "scissors"]
return random.choice(options)


def decide_winner(player, computer):
"""Decide the winner based on the choices."""
if player == computer:
return "It's a draw!"
elif (
(player == "rock" and computer == "scissors")
or (player == "paper" and computer == "rock")
or (player == "scissors" and computer == "paper")
):
return "You win!"
else:
return "Computer wins!"


def main():
"""Main function to play the game."""
user_choice = get_user_choice()
computer_choice = get_computer_choice()
print(f"Computer chose: {computer_choice}")
print(decide_winner(user_choice, computer_choice))


if __name__ == "__main__":
main()