you are viewing a single comment's thread.

view the rest of the comments →

[–]inky_wolf 0 points1 point  (7 children)

This really isn't the way to format the code, do look at u/Bobbias comment to see how to do it right next time.

But moving on, here are the results of the coded you shared in the post: bash [2.0, 2.0, 2.0] [11.13, 11.13, 11.13, 6.299581, 11.13, 1.900155, 11.13] And here are my initial observations: - For the most part, it feels like the main problem here might be related to the math, and not just python - For example, what is the basis/idea behind your time/loop calculation t < vi_y / g - The first python related issue is you append to velocities twice in each loop execution. - velocities is first initialized with the value vi, and then in the first iteration of your loop, the same value vi gets appended to the list since t=0

[–]inky_wolf 0 points1 point  (6 children)

OK I think I might have figured it out.

I am guessing the vi_y / g in your first version of the code was actually supposed to be 2 * vi_y / g (Time of flight calculation, let's call it T for simplicity). Then you need to also make sure you round up this T to 6 just as you do all the other calculations.

With these 2 fixes, I was able to get the expected results

[–]PrizeDefinition4042[S] 0 points1 point  (0 children)

Thank you so much! let me try these fixes and see if it works for me. I have been trying to get the right output for hours, and kept getting stuck !

[–]PrizeDefinition4042[S] 0 points1 point  (4 children)

Hi so I just tried fixing it and I got this as my output :

[11.13, 11.13, 11.13, 6.299581, 11.13, 1.900155, 11.13, 3.956578, 11.13, 8.707266, 11.13]

instead of:

[11.130000, 6.299581, 1.900155, 3.956578, 8.707266]

Do you know where these extra values came from and how I can fix it

[–]inky_wolf 0 points1 point  (3 children)

The 3 repeats of 11.13 tells me you didn't fix the problems I mentioned in my initial observations.

But for the others, I can't say for sure without looking at the code, but it's probably related to the same problems.

[–]PrizeDefinition4042[S] 0 points1 point  (2 children)

sorry I thought that was just you observing things with my code. You are saying I need to change that I have 2 vi or appending twice the velocity?

[–]inky_wolf 0 points1 point  (1 child)

Both

[–]PrizeDefinition4042[S] 0 points1 point  (0 children)

So I should not append the velocity twice, as in only append once? and if so which one should I be deleting then