def RewardCalculation(correct, taken, isExtra):
compensation = 0
if taken >= 600:
compensation -= (taken-600)/60
else:
if correct == 10:
compensation += 10
if taken <= 60:
compensation += 30
elif taken <= 120:
compensation += 20
elif taken <= 180:
compensation += 10
else:
wrong = 10-correct
compensation = -(wrong*5)
if isExtra == True:
if compensation > 0:
return(compensation)
else:
return("compensation > 0")
else:
return(compensation)
Python
내가 연산 연습을 한 뒤 틀린 문제 수와 걸린 시간에 따른 보상을 계산해주는 코드
함수에는 맞은 문제 수(전체 10문제, Number), 걸린 시간(초, Number), 하고싶어서 더하는 추가인지(Boolean)이 매개변수로 들어가며 분 단위로 보상이 리턴된다.
현재 맥의 /Users/imac/python/RewardCalculation.py에 있다.
'일기' 카테고리의 다른 글
해멍 (1) | 2024.08.11 |
---|---|
컴퓨터를 사용하는 것 (0) | 2024.08.11 |
멈춘 시계 (2) | 2024.06.03 |
신도림역에서 기차 관찰 (0) | 2024.05.27 |
발꼬랑내 (0) | 2024.05.27 |