1D Kinematic Equations Calculator
This program takes in information from a 1D Kinematic Equations problem and automatically solves for the answer. You don't even have to enter an equation.
Here's another tip. Instead of repeating the input code multiple times for each variable, you could make a function to make it much more versatile. Here is an example of a function
def get_input(text): # This line creates the function, get_input, with the parameter of text while True: # You can create a while loop to keep running the code until you get the value you want val = input(text + " ") if val.strip().lower() == "nn" and val.strip() != "?": # This checks to see if the value is NN # I like using the strip and lower functions # in order to allow for a wider array of inputs return "NN" # By using try and except the program won't return an error # if the program throws an error try: return float(val) # It will try to run this and if it doesn't work it will run except except: print("Please try again with a float or NN\n\n") continue # This keyword runs the for loop again # Now we can call this function as much as we want v = get_input("Enter the velocity") # The output of the function is assigned to the variable print("Velocity", v) t = get_input("Enter the Time") print("Time", t) print("\n\nDistance is", v*t)
Using functions makes code much cleaner and easier to change.