![[Python] 조건문 연습4](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F1ruXt%2FbtsHjArh3yL%2Fd4a0c4f6GZwJvIzdafnZ01%2Fimg.png)
- PC가 난수(1 ~ 1000)를 발생하면 사용자가 숫자(정수)를 입력한다 - 사용자가 난수를 맞추면 게임이 종료된다. - 만약, 못 맞추게 되면 난수와 사용자 숫자의 크고 작음을 출력한 후 사용자한테 다시 기회를 준다. - 최종적으로 사용자가 시도한 횟수를 출력한다. import randomrandomNum = random.randint(1, 1000)tryCnt = 0gameFlag = Truewhile gameFlag: tryCnt += 1 userNum =int(input('1에서 1,000까지의 정수 입력: ')) if randomNum == userNum: print('정답!') gameFlag = False else: ..
![[Python] 조건문 연습2](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcWltOS%2FbtsHgZ0oHW6%2FIs06oFSe0GX1repUgcsko0%2Fimg.png)
난수를 이용해서 가위, 바위, 보 게임 import randomcomNum = random.randint(1, 3)userNum = int(input('1. 가위 | 2. 바위 | 3. 보 (숫자입력) >>> '))if ((comNum == 1 and userNum == 2) or (comNum == 2 and userNum == 3) or (comNum == 3 and userNum == 1)): print('컴퓨터는 {}번! '.format(comNum), end='') print('컴퓨터 패!')elif comNum == userNum: print('컴퓨터는 {}번! '.format(comNum), end='') print('무승부!!')else: ..
1~6까지의 수를 랜덤으로 추출하여 '주사위 : 1칸 전진' 출력 public class SwitchRandom { public static void main(String[] args) { // 1~6까지의 랜덤 생성 int dice = (int)(Math.random()*6)+1; //랜덤 수에 따른 출력 switch(dice) { case 1: System.out.println("주사위 : "+dice+"칸 전진"); break; case 2: System.out.println("주사위 : "+dice+"칸 전진"); break; case 3: System.out.println("주사위 : "+dice+"칸 전진"); break; case 4: System.out.println("주사위 : "+dic..