Skip to content

Commit a0392d8

Browse files
author
chaerishme
committed
comment: 독스트링 추가
1 parent 734bea8 commit a0392d8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/racingcar/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33

44
def main():
5+
"""
6+
프로그램을 실행하고, 자동차 경주의 시뮬레이션을 수행하는 함수
7+
사용자로부터 자동차 이름과 시도 횟수를 입력받고, 각 시도마다
8+
경주를 진행하여 최종 우승자를 출력.
9+
"""
510
print("프로그램이 시작되었습니다.")
611

712
car_names = input("경주할 자동차 이름을 입력하세요.(이름은 쉼표로 구분)\n")
@@ -27,11 +32,18 @@ def main():
2732
print_winner(cars, car_positions)
2833

2934
def movement(cars, car_positions):
35+
"""
36+
각 자동차가 0에서 9 사이의 랜덤 숫자를 생성하여,
37+
4 이상의 숫자가 나오면 해당 자동차의 위치를 1 증가시키는 함수
38+
"""
3039
for car in cars :
3140
if random.randint(0,9) >= 4 :
3241
car_positions[car] += 1
3342

3443
def get_winner(cars, car_positions):
44+
"""
45+
경주에서 우승한 자동차를 구하는 함수입니다.
46+
"""
3547
max_value = max(car_positions.values())
3648
return [car for car in cars if car_positions[car] == max_value]
3749

0 commit comments

Comments
 (0)