Share your repls and programming experiences

← Back to all posts
1D Kinematic Equations Calculator
BlueFalcon23 (6)

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.

Comments
hotnewtop
AkeBoss (2)

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.

RoBlockHead (442)

oh hey this is pretty poggers! Kinematics is hard, love to see that someone's making calculators!

DynamicSquid (4635)

Cool! Just a tip: on line 196 you could have the keyword break to exit the loop instead.

vomejok509 (0)

Finally someone is touching this part, kudos to you! https://tutuappx.com/
https://vidmate.onl/