Skip to content
Open
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
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
"extensions": [
"streetsidesoftware.code-spell-checker",
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"GitHub.copilot"
]
}
},



// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [9000],
Expand Down
53 changes: 53 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import random

def determine_winner(player_choice, computer_choice):
if player_choice == computer_choice:
return "Tie"
elif (player_choice == "rock" and computer_choice == "scissors") or \
(player_choice == "scissors" and computer_choice == "paper") or \
(player_choice == "paper" and computer_choice == "rock"):
return "Win"
else:
return "Lose"

def print_result(result):
if result == "Win":
print("Congratulations! You won!")
elif result == "Lose":
print("Sorry! You lost.")
else:
print("It's a tie!")

def main():
player_score = 0
rounds_played = 0

while True:
player_choice = input("Enter your choice (rock, paper, or scissors): ").lower()
if player_choice not in ["rock", "paper", "scissors"]:
print("Invalid option! Please choose from rock, paper, or scissors.")
continue

computer_choice = random.choice(["rock", "paper", "scissors"])
print("Computer chose:", computer_choice)

result = determine_winner(player_choice, computer_choice)
print_result(result)

if result == "Win":
player_score += 1
elif result == "Lose":
player_score -= 1

rounds_played += 1

play_again = input("Do you want to play again? (yes/no): ").lower()
if play_again != "yes":
break

print("Game over!")
print("Your final score:", player_score)
print("Total rounds played:", rounds_played)

if __name__ == "__main__":
main()