test01-1.py

from random import random

mine = ""
com = ""
result = ""

mine = input("가위바위보 입력 ")

rnd =random()
if rnd > 0.66 :
    com ="가위"
elif rnd > 0.33:
    com ="바위"
else :
    com ="보"
print("com",com)    

if com == mine :
    result = "비김"
elif com =="가위" and mine=="바위" or com=="바위" and mine=="보" or com=="보" and mine=="가위":
    result = "이김"
else :
    result ="짐"  
    
print("mine",mine)     
print("결과 : ",result)

test01-2.py

from random import random

com = ""
mine = ""
result = ""

mine = input("가위바위 보를 입력하세요") 

rnd = random()
if rnd > 0.66 :
    com ="가위"
elif rnd > 0.33 :    
    com = "바위"
else :
    com ="보"    

if com == "가위" and mine ="가위" result="비김"
if com == "가위" and mine ="바위" result="승리"
if com == "가위" and mine ="보" result="패배"

if com == "바위" and mine ="바위" result="비김"
if com == "바위" and mine ="보" result="승리"
if com == "바위" and mine ="가위" result="패배"

if com == "보" and mine ="보" result="비김"
if com == "보" and mine ="가위" result="승리"
if com == "보" and mine ="바위" result="패배"

print("나",mine)
print("컴",com)
print("결과 : ",result)

'파이썬' 카테고리의 다른 글

[파이썬] 다중상속  (0) 2023.02.21
[파이썬] 상속  (0) 2023.02.21
[파이썬] 함수(def)  (0) 2023.02.20
[파이썬] test  (0) 2023.02.20
[파이썬] for,input,random  (0) 2023.02.20

+ Recent posts