-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatuGuntingKertas.py
39 lines (29 loc) · 1.02 KB
/
batuGuntingKertas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import random
user_menang = 0
sistem_menang = 0
pilihan = ["batu", "kertas", "gunting"]
while True:
user_input = input("Ketik Batu/Ketas/Gunting : ").lower()
if user_input == "q":
break
if user_input not in pilihan:
continue
random_angka = random.randint(0,2)
sistem_pilih = pilihan[random_angka]
print("Sistem memilih", sistem_pilih + ".")
if user_input == "batu" and sistem_pilih == "gunting":
print("Kamu Menang !!!")
user_menang += 1
elif user_input == "kertas" and sistem_pilih == "batu":
print("Kamu Menang !!!")
user_menang += 1
elif user_input == "gunting" and sistem_pilih == "kertas":
print("Kamu Menang !!!")
user_menang += 1
else :
print("Kamu Kalah !!!")
sistem_menang += 1
print("===============================================")
print("Kamu Menang", user_menang, "kali.")
print("Sistem Menang", sistem_menang, "kali.")
print("Terima Kasih Sudah Bermain !!!")