Python/python 개발 23

파이썬 플레이어VS보스 코드

결과물 코드 복사코드 import random def play(): playerhp=100 bosshp=100 playerattack=10 bossattack=10 print("게임을 시작합니다.\n") print("player vs boss\n") while(True): boss=random.randint(1,3) #보스패턴 1)공격 2)버프 3) 회복 print("\n플레이어 체력 : ",playerhp," 보스 체력 : ",bosshp) print("\n플레이어 공격력 : ",playerattack," 보스 공격력 : ",bossattack) menu=int(input("\n\n선택 1)공격 2)방어 3)버프 4)도망 : ")) if(menu==1): bosshp=bosshp-playerattack..

파이썬 로또 추첨 코드(1) 부족

결과물 코드 아쉬운점 -> 같은 숫자가 나오지 않게 하기위해 숫자를 비교해가며 걸러내기식으로 해봤지만 마지막 보너스번호에서 겹치는 부분이 나오게된다. 복사코드 import random n=[0,0,0,0,0,0,0] print("로또 추첨\n") n[0]=random.randint(1,46) n[1]=random.randint(1,46) while(True): if(n[0]==n[1]): n[1]=random.randint(1,45) else: break n[2]=random.randint(1,45) while(True): count1=0 for i in range(0,2): if(n[i]==n[2]): n[2]=random.randint(1,45) count1=count1+1 if count1>1: c..

python 가위, 바위, 보 게임 코드

결과물 코드 복사코드 import random print("가위 바위 보 게임\n\n") def func1(): print("게임을 시작합니다. 3승리 조건\n") Pcount=0 Ccount=0 while(1): print("\n") menu=int(input("선택 1)가위 2)바위 3)보 : ")) com=random.randint(1,3) #컴퓨터 1)가위 2)바위 3)보 if(menu==1): if(com==1): print("플레이어 : 가위, 컴퓨터 : 가위, 결과 무승부\n\n") print("승리표시 플레이어 : ",Pcount," 컴퓨터 : ",Ccount) elif(com==2): print("플레이어 : 가위, 컴퓨터 : 바위, 결과 컴퓨터 승!\n") Ccount=Ccount+1 ..