Skip to content

Commit 0e61ffc

Browse files
Add doctest for player progress
1 parent c5510b9 commit 0e61ffc

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

cse231/number_guessing_game.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ def is_good_number(number):
1414
Let's a user know whether a number is properly formed.
1515
Each number should be 5 digits long and should not repeat numbers.
1616
17+
:param number: int
18+
:return: boolean
19+
1720
>>> is_good_number(12345)
1821
True
1922
>>> is_good_number(55432)
2023
False
2124
>>> is_good_number(444)
2225
False
23-
24-
:param number: int
25-
:return: boolean
2626
"""
2727
if not number:
2828
return False
@@ -63,12 +63,43 @@ def report_results(user_number, secret_number):
6363
Report how many digits are correct.
6464
Report how many digits are in correct position.
6565
66+
:return: tuple
67+
6668
>>> report_results(54321, 12345)
67-
'Digits correct: 5'
68-
'Digits in correct position: 0'
69+
(5, 0)
70+
"""
71+
return 5, 0
72+
pass
73+
74+
75+
def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digits):
76+
"""
77+
Report the player's current progress.
6978
79+
Nums of guesses, their guess, num of correct digits,
80+
and num of digits in the correct position.
81+
82+
:param num_of_guesses: int
83+
:param user_guess: str
84+
:param correct_digits: int
85+
:param correct_pos_digits: int
7086
:return: str
87+
88+
>>> player_progress(5, '12345', 4, 3)
89+
------------------------------
90+
Used guesses: 5
91+
User guess: 12345
92+
Digits correct: 4
93+
Digits in correct position: 3
94+
------------------------------
7195
"""
96+
97+
print('------------------------------')
98+
print('Used guesses: {}'.format(5))
99+
print('User guess: {}'.format('12345'))
100+
print('Digits correct: {}'.format(4))
101+
print('Digits in correct position: {}'.format(3))
102+
print('------------------------------')
72103
pass
73104

74105

0 commit comments

Comments
 (0)