I’m working on a for-fun-project that I will be doing some calculations with and I need some help.
one module from my program:
def ARK(rawArk):
refArk = rawArk/200
arkTrit = refArk*300
arkMeg = refArk*333
arkZyd = refArk*166
print "Totals from your Arkonor:"
print "Tritanium=", arkTrit
print "Megacyte=", arkMeg
print "Zydrine=", arkZyd
return arkTrit, arkMeg, arkZyd
Right now it is just doing simple division and multiplication. What I want to do is be able to do this with remainders.
So if ‘refArk = rawArk/200’ gives a total of 16.3, I want to be able to separate the 16.0 and the 0.3 and use them as separate variables for separate calculations.
So far:
def ARK(rawArk):
refArk = float(rawArk/200)
arkTrit = refArk*300
arkMeg = refArk*333
arkZyd = refArk*166
print "Totals from your Arkonor:"
print "Tritanium=", arkTrit
print "Megacyte=", arkMeg
print "Zydrine=", arkZyd
strval = str(refArk)
head,tail = strval.split(".")
whole = float(head)
frac = float("."+tail)
print whole
print frac
return arkTrit, arkMeg, arkZyd
def main():
rawArk=input("How much Arkonor?")
ARK(rawArk)
return
main()
USING ‘450’ as my input value
returns
How much Arkonor?450
Totals from your Arkonor:
Tritanium= 600.0
Megacyte= 666.0
Zydrine= 332.0
2.0
0.0
The 2.0 is right but the 0.0 should be 0.25
Removing the float() from the ‘rawArk/200’ spits out an error:
How much Arkonor?450
Totals from your Arkonor:
Tritanium= 600
Megacyte= 666
Zydrine= 332
Traceback (most recent call last):
File "E:\eve stuff\Calculator\test.py", line 23, in <module>
main()
File "E:\eve stuff\Calculator\test.py", line 20, in main
ARK(rawArk)
File "E:\eve stuff\Calculator\test.py", line 11, in ARK
head,tail = strval.split(".")
ValueError: need more than 1 value to unpack
Numerically
Kind of a hack but with strings
either way