programming help
i need help on how to start
i wanna try calculating distance like the example
@ultrilliam
@smokeybrown
in order to start this, you'll need to think about the math/logic first if you want to calculate the distance between two points, for example, remember that the distance formula is \[\sqrt{(x_{2}-x_{1})^{2}+(y_{2}-y_{1})^{2}}\] where (x1,y1) are the coordinates of the first point, and (x2,y2) are the coordinates of the second point. you'll need to have an input prompt that lets the user enter the x1, y1, and x2, y2 values something like x1 = float(input("What is the value of your first x-coordinate?")) normally, input treats the input as a string, but since you want to do calculations with the input, it has to be converted to a float and repeat for all the necessary values of the calculation
then you'll need to set up the formula in python, you can import the math module to get access to the square root function so at the top of your program, you could write from math import * then math.sqrt() will calculate the value of the number inside the parentheses. also remember that double ** gives you exponentiation (ex: 3 ** 2 is 3^2 or 9) using these, you can program the formula and store the result. then print the result.
if you want to do some other type of calculation, the logic is the same. think about the actual math, then think about how to convert the values/formulas/etc. into code. then write the program, test some values, display the output, check if the program works and gives you the right result.
@vocaloid thank you so much this really helped me out
Join our real-time social learning platform and learn together with your friends!