diff options
| author | mrdog233o5 <mr.dog233o5@gmail.com> | 2023-10-24 00:38:19 +0800 |
|---|---|---|
| committer | mrdog233o5 <mr.dog233o5@gmail.com> | 2023-10-24 00:42:03 +0800 |
| commit | a36545436fdba381018b7c68e0d58de16ece4a0c (patch) | |
| tree | 22bc7d1a1814ca1d4201835b181953564e6be7b9 | |
| parent | 616ce6761545e62a83a6a214febc404c1e2da5f7 (diff) | |
rock paper sissor done
| -rw-r--r-- | rockPaperSissor.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rockPaperSissor.py b/rockPaperSissor.py new file mode 100644 index 0000000..fe2d6e5 --- /dev/null +++ b/rockPaperSissor.py @@ -0,0 +1,33 @@ +import random + +def game(): + print("choose:\n1 - rock \n2 - paper \n3 - sissor") + player = int(input("> ")) + bot = random.randint(1,3) + if player > bot and abs(player-bot) != 2: + return 1 + else: + return 0 + +print("Win two out of three games(1) or decide the outcome in one game(2)?") +mode = input("enter a number > ") +match mode: + case "1": + resultReal = 1 + for i in range(3): + result = game() + if result: + print(f"player win this round!") + else: + print(f"bot win this round!") + resultReal = resultReal + result + if resultReal <= 2: + print("\nbot win the game!") + else: + print("\nplayer win the game!") + case "2": + result = game() + if result: + print(f"player win!") + else: + print(f"bot win!") |
