I have a code that solves a specifically math question, and I want it to run a certain number of times, with differents inputs. How could I do that, without clicking on the run button?
This is my code at the moment:
from math import log as ln
from math import sqrt as sq
import scipy.stats as st
from math import e
def opsjonsprising():
IK = float(input("Skriv inn innløsningskursen: "))
SK = float(input("Skriv inn startkursen: "))
beta = float(input("Skriv inn beta verdien: "))
rente = float(input("Skriv inn bankrenten: "))
tid = float(input("Skriv inn tid for innløsning: "))
P = (rente / 100)
B = (beta / 100)
T = (tid / 12)
R = ln((IK / SK)) + (((1 / 2) * (B ** 2) - P) * T)
S = B * sq(T)
A = ((R / S) - S)
G = (st.norm.cdf(A))
V = (SK * (1 - G)) - ((IK * e ** (- (P * T))) * (1 - (st.norm.cdf(R / S))))
Ans = round(float(V), 2)
Big_R = round(float(R), 4)
Big_S = round(float(S), 4)
Big_G = round(float(G), 4)
print("R = " + str(Big_R))
print("S = " + str(Big_S))
print("G = " + str(Big_G))
print("Prisen per opsjon er: " + str(Ans) + " kr")
opsjonsprising()
def restart():
restart = input("Vil du kjøre koden en gang til? ")
if restart == "ja":
opsjonsprising()
else:
print(("Håper du er fornøyd med svaret"))
restart()