Too lazy to solve math equations? This program will help!

While looking for assignments to pick out of, I found that there was an assignment bank for coding. While being a coding nerd myself, I had to check it out. Even though there was only one thing listed, I was excited to even do it. I’m trying to minor in computer science, and for awhile I wanted to double major with it. So it’s easy to say I love coding.

Since the program was only supposed to be 10-20 lines, there wasn’t much I could do with that. So I decided to make the program about calculating the slope of a function.

Even though I am a math major currently, ever since I was young- for some odd reason- I could never remember the equation for this function. Was it (y1 – y2) / (x1 – x2) or (x2 – x1) / (y2 – y1)? For reference, both of those are wrong, the actual equation is (y2 – y1) / (x2 – x1). I just always had a problem with that equation. So having a program to solve that seemed like a good idea for me. In the end, this program only helps people who A. struggle like me with this equation or B. are too lazy to figure it out on their own.

This honesty didn’t take me long. The longest thing to do was making sure that the program was formatted nicely. Other than that, this really didn’t take me longer than 5-10 minutes. I did this off Python, as it’s the only coding program I have on my laptop.

Description of Activity: “Create a simple program, 10-20 lines, where your code can solve a simple problem. Feel free to use an online compiler to write and test your code.”

Code:

print(“Hello User! This program is to help you with solving for a slope.”)
name = input(“Before we start, what’s your name? “)
print(“”)
print(“Okay, “, name, “, I’ll be needed two plot points.”, sep=””)
print(“x1, y1 should be one point and x2, y2 should be another.”)
x1 = float(input(“What’s your x1 point? “))
x2 = float(input(“What’s your x2 point? “))
y1 = float(input(“What’s your y1 point? “))
y2 = float(input(“What’s your y2 point? “))
slope = (y2 – y1) / (x2 – x1)
print(“Your slope is:”, slope)
print(“Thank you for using this program, “, name, “!”, sep=””)

4 Replies to “Too lazy to solve math equations? This program will help!”

  1. Nice! I tested this out in python and it worked fine. I thought about doing this as an assignment this week, but I couldn’t think of a program to do since I have already forgotten the python I learned last semester. I’m a CS major, so I guess I’d better brush up on it!

    1. Python was the second one I learned, my first one (that I’ve also forgotten) was Blue Jay! My brother is more of the computer genius in our family. He knows a ton of programs, so he helps me on ones I don’t know!

Leave a Reply

Your email address will not be published. Required fields are marked *