코딩도장

코딩도장

변경이력

돌아가기
2 73개 문자 추가 31개 문자 삭제

2024年04月22日 11:29

예즤YeZ

```{.python}from random import randint '''generating password''' def generate_password(): password = [] print('YOUR PASSWORD IS 3-DIGITS NUMBER(there\'s no repetition)\n') while len(password) < 3: num = randint(0, 9) if num not in password: password.append(num) return password '''input password''' def user_input(): guess = [] print('ENTER PASSWORD') while len(guess) < 3: num = int(input('digit: ')) guess.append(num) return guess '''check''' def check(answer, user): right = 0 for i in range(0, 3): if user[i] in answer: right += 1 print('{} of them is/are right\n'.format(right)) '''start''' ANSWER = generate_password() while True: user_guess = user_input() check(user_guess, ANSWER) if user_guess == ANSWER: break print('UNLOCKED!') ``` 온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
```{.python}from random import randint '''generating password''' def generate_password(): password = [] print('YOUR PASSWORD IS 3-DIGITS NUMBER(there\'s no repetition)\n') while len(password) < 3: num = randint(0, 9) if num not in password: password.append(num) return password '''input password''' def user_input(): guess = [] print('ENTER PASSWORD') while len(guess) < 3: num = int(input('digit: ')) guess.append(num) return guess '''check''' def check(answer, user): right = 0 for i in range(0, 3): if user[i] in answer: right += 1 print('{} of them is/are right\n'.format(right)) '''start''' ANSWER = generate_password() while True: user_guess = user_input() check(user_guess, ANSWER) if user_guess == ANSWER: break print('UNLOCKED!') ``` 온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
```{.python}from random import randint '''generating password''' def generate_password(): password = [] print('YOUR PASSWORD IS 3-DIGITS NUMBER(there\'s no repetition)\n') while len(password) < 3: num = randint(0, 9) if num not in password: password.append(num) return password '''input password''' def user_input(): guess = [] print('ENTER PASSWORD') while len(guess) < 3: num = int(input('digit: ')) guess.append(num) return guess '''check''' def check(answer, user): right = 0 for i in range(0, 3): if user[i] in answer: right += 1 print('{} of them is/are right\n'.format(right)) '''start''' ANSWER = generate_password() while True: user_guess = user_input() check(user_guess, ANSWER) if user_guess == ANSWER: break print('UNLOCKED!') ``` 온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
1 Original

2024年04月22日 11:20

예즤YeZ

```{.python} from random import randint '''generating password''' def generate_password(): password = [] while len(password) < 3: num = randint(0, 9) if num not in password: password.append(num) return password '''input password''' def user_input(): guess = [] print('ENTER PASSWORD') while len(guess) < 3: num = int(input('digit: ')) guess.append(num) return guess '''check''' def check(answer, user): right = 0 for i in range(0, 3): if user[i] in answer: right += 1 print('{} of them is/are right\n'.format(right)) '''start''' ANSWER = generate_password() while True: user_guess = user_input() check(user_guess, ANSWER) if user_guess == ANSWER: break print('UNLOCKED!') ``` 온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
```{.python} from random import randint '''generating password''' def generate_password(): password = [] while len(password) < 3: num = randint(0, 9) if num not in password: password.append(num) return password '''input password''' def user_input(): guess = [] print('ENTER PASSWORD') while len(guess) < 3: num = int(input('digit: ')) guess.append(num) return guess '''check''' def check(answer, user): right = 0 for i in range(0, 3): if user[i] in answer: right += 1 print('{} of them is/are right\n'.format(right)) '''start''' ANSWER = generate_password() while True: user_guess = user_input() check(user_guess, ANSWER) if user_guess == ANSWER: break print('UNLOCKED!') ``` 온라인 강의에서 배운 코드를 변형해서 사용해봤습니다!
코딩도장

코딩도장은 프로그래밍 문제풀이를 통해서 코딩 실력을 수련(Practice)하는 곳입니다.

코딩도장 © 2014 · 문의 [email protected]
피드백 · 개인정보취급방침 · RSS

AltStyle によって変換されたページ (->オリジナル) /