I'm seeming to have an issue with running this code that I made:
def acidhenderson():
ka = input("Enter a Ka value: ")
pka = math.log(float(scientific_string(ka)), 10) * -1
base = float(scientific_string(input("Enter base concentration: ")))
acid = float(scientific_string(input("Enter acid concentration: ")))
ph = pka + math.log((base / acid), 10)
print("pH = " + str('%.2f' % ph) + ".")
print("")
main()
def main():
print("1: Calculate pOH of a buffer from Kb (Henderson Hasselbalch equation)")
print("2: Calculate pH of a buffer from Ka (Henderson Hasselbalch equation)")
print("3: Calculate the ratio of base/acid from pH and Ka")
print("4: Solve an ICE table")
choice = input("What would you like to do?: ")
if choice == "1":
basehenderson()
if choice == "2":
acidhenderson()
if choice == "3":
acid_base_ratio()
if choice == "4":
icesolver()
if choice == "exit" or "quit":
return
main()
def scientific_string(string):
string_list = list(string)
i = 0
while i < len(string_list):
if string_list[i] == "^":
string_list[i] = "**"
return_var = ''.join(string_list)
return eval(return_var)
i = i + 1
return_var = ''.join(string_list)
return eval(return_var)
If I input the number 2, it should go to the function acidhenderson() (I didn't put the other functions as it would take a lot of room), but instead in linux it just returns to the next line like this:
root@debian:~/Documents/code/eq# python equilibrium.py
1: Calculate pOH of a buffer from Kb (Henderson Hasselbalch equation)
2: Calculate pH of a buffer from Ka (Henderson Hasselbalch equation)
3: Calculate the ratio of base/acid from pH and Ka
4: Solve an ICE table
What would you like to do?: 2
root@debian:~/Documents/code/eq#
I am relatively new to Linux but I'm thinking that this may be a Linux problem rather than a python code problem but I'm not too sure. Can anyone help?