Ask your own question, for FREE!
Computer Science 15 Online
Gucchi:

programming help

Gucchi:

1 attachment
Gucchi:

1 attachment
Gucchi:

i need help on how to start

Gucchi:

i wanna try calculating distance like the example

Gucchi:

@ultrilliam

Gucchi:

@smokeybrown

Vocaloid:

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

Vocaloid:

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.

Vocaloid:

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.

Gucchi:

@vocaloid thank you so much this really helped me out

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!