python - Answered Calculator -
i've looked around people have done haven't been getting results. following formula off website (here link) http://www.serebii.net/games/damage.shtml . using python 3+ here code. (note have left out random number) keep getting syntax error.
level = int(input('please enter pokemons level :' )) attackstat= int(input('please enter pokemons special/attack stat : ')) defensestat= int(input('please enter opponents special/defense stat : ')) attackpower= int(input('please enter moves base attack : ')) answer= str('is move stab? : ') stab= if answer == yes: stab= 1.5 else: stab= 1 answer1= int('how effective move?') resistance= if answer1== 4: resistance= 4 if answer1== 2: resistance= 2 if answer1== 1: resistance= 1 if answer1== 0.5: resistance= 0.5 if answer1== 0.25: resistance= 0.25 damage= (((2* level/5 +2) * attackstat * attackpower/ defensestat)/50)+2)*stab*resistance/100 print (damage)
well:
resistance= if answer1== 4: resistance= 4 if answer1== 2: resistance= 2 if answer1== 1: resistance= 1 if answer1== 0.5: resistance= 0.5 if answer1== 0.25: resistance= 0.25
give error in python. write:
if answer1== 4: resistance= 4 if answer1== 2: resistance= 2 if answer1== 1: resistance= 1 if answer1== 0.5: resistance= 0.5 if answer1== 0.25: resistance= 0.25
and better:
if answer1== 4: resistance= 4 elif answer1== 2: resistance= 2 elif answer1== 1: resistance= 1 elif answer1== 0.5: resistance= 0.5 elif answer1== 0.25: resistance= 0.25
and (same):
stab= if answer == yes: stab= 1.5 if answer == "yes": stab = 1.5 else: stab = 1
and better
resistance = answer1
or
if answer1 in [4, 2, 1, 0.5, 0.25]: resistance = answer1
Comments
Post a Comment