I would like to reset/restart my program but based on a user input. So say if the user types "yes" and clicks enter, the program will reset/restart and start fresh. I am making a calculator for energy; Physics problems. The out puts are Mechanical Energy, Kinetic Energy, and Potential Energy. All the formulas are coded properly, everything is working as expected, except I have no way to restart the program without clicking back on the file and reopening.
#Importing "time" and "math" so I can use the time.sleep and rounding functions
import time
import math
restart=1
user_r1=float(input ("What is the mass of your object (kg) = "))
print ("")
user_r2=float(input ("Whats is the height you are dropping from (m) = "))
print ("")
user_r3=float(input ("What is the velocity (m/s) = "))
#Formulas that solve from the inputs given
EKinetic = 0.5 * user_r1 * user_r3 * user_r3
EPotential = user_r1 * 9.81 * user_r2
MechEnergy = (EPotential) + (EKinetic)
#Rounding - To change the ammount of sigdigs change the # infront of the f'
EKinetic='%.1f' % EKinetic
EPotential='%.1f' % EPotential
MechEnergy='%.1f' % MechEnergy
#Spitting out the info the user will see
print ("")
print ("===============================================================================")
print ("Kinetic Energy = ",EKinetic,"J")
print ("")
print ("Potential Energy = ",EPotential,"J")
print ("")
print ("Mechanical Energy = ",MechEnergy,"J")
print ("===============================================================================")
print ("")
#This time.sleep will make the program pause for (x# of seconds)
time.sleep(3)
user_r4=(input ("To do another calculation type yes and hit enter = "))
if user_r4 == ("yes"):
print ("YAY")
###PUT RESTART CODE HERE###
###EVERYTHING DOWN ARE JUST PLACE HOLDERS FOR THE RESTART CODE###
else:
print ("Please type yes to continue")
time.sleep(1)
user_r4=(input ("To do another calculation type yes and hit enter = "))
if user_r4 == ("yes"):
print ("YAY")
###PUT RESTART CODE HERE###
else: print ("Thats enough!!!")
time.sleep(3)
goto.