from pyscript import document import math def berekening(event): resultaat = "" a = document.getElementById("zijde_a").value b = document.getElementById("zijde_b").value c = document.getElementById("zijde_c").value # c berekenen if a != "" and b != "" and c == "": zijdeA = float(a) zijdeB = float(b) joe = (zijdeA ** 2) + (zijdeB ** 2) zijdeC = math.sqrt(joe) afgerond = round(zijdeC,1) resultaat = "Zijde c is: " + str(afgerond) # b berekenen elif a != "" and b == "" and c != "": zijdeA = float(a) zijdeC = float(c) joe = (zijdeC ** 2) - (zijdeA ** 2) if joe < 0: resultaat = "Fout: zijde c moet groter zijn dan zijde a." else: zijdeB = math.sqrt(joe) afgerond = round(zijdeB,1) resultaat = "Zijde b is: " + str(afgerond) # a berekenen elif a == "" and b != "" and c != "": zijdeB = float(b) zijdeC = float(c) joe = (zijdeC ** 2) - (zijdeB ** 2) if joe < 0: resultaat = "Fout: zijde c moet groter zijn dan zijde b." else: zijdeA = math.sqrt(joe) afgerond = round(zijdeA,1) resultaat = "Zijde a is: " + str(afgerond) elif a != "" and b != "" and c != "": resultaat = "Je weet alle zijden al." else: resultaat = "Je moet minstens twee zijden invullen." document.querySelector("#output").innerText = resultaat