-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(curriculum): add Projectile Trajectory project to SciComPy #54839
base: main
Are you sure you want to change the base?
feat(curriculum): add Projectile Trajectory project to SciComPy #54839
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the tests are fixed, instructions can be refined a bit for the last steps but it's looking very good!
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/662f9f65c50bd21d05ffdee9.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/662f9f65c50bd21d05ffdee9.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6634fa2417d7194b0c9425f9.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66335223f3e2a31d62d84367.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/663353465bfb14259717da93.md
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66475d40dd42fb614f14fd03.md
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66475e40f3891c645d50135e.md
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66475f7b91d7c6681987739d.md
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6633bdc3ca38c068c3735984.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6633bdc3ca38c068c3735984.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the project and left a few comments.
Also, I wasn't able to pass the steps 18, 19 and 20.
Some steps(like step-2) are too wordy and would need to be revised.
Once Dario's reviews are resolved, I'll take another thorough look.
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/660400f02cf3a76795b82d4e.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/65fd4b3bedee044b4b957d33.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/660fcf3e1b9bb056b2edb567.md
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/660fcf3e1b9bb056b2edb567.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/662fc35902038376c7a00b3c.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6633c06601c081735063b528.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66475e40f3891c645d50135e.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/660400f02cf3a76795b82d4e.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66335223f3e2a31d62d84367.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/663353465bfb14259717da93.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through the steps. Looks fine to me. I managed to pass all the steps. The text looks great too.
@@ -874,6 +874,10 @@ | |||
"This is one of the required projects to claim your certification." | |||
] | |||
}, | |||
"learn-encapsulation-by-building-a-projectile-trajectory-calculator": { | |||
"title": "Learn Encapsulation by Building a Projectile Trajectory Calculator", | |||
"intro": ["", ""] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to add intro.
"usesMultifileEditor": true, | ||
"hasEditableBoundaries": true, | ||
"dashedName": "learn-encapsulation-by-building-a-projectile-trajectory-calculator", | ||
"order": 221, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to check the order.
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/65fd4b3bedee044b4b957d33.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6616ec0bf9ee8548ce6b0f08.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6633b4d3271d5b3aea1c1195.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/6633bdc3ca38c068c3735984.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/663353465bfb14259717da93.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Zaira <33151350+zairahira@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed all the steps, the tests ran fine for all of them.
I have left a couple of comments, after that the project is ready to go from my end.
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/662f9f65c50bd21d05ffdee9.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/662fa453ec8033322b3ab2e3.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/66475bab40e5125c84b03337.md
Outdated
Show resolved
Hide resolved
...arn-encapsulation-by-building-a-projectile-trajectory-calculator/660400f02cf3a76795b82d4e.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be fleshed out, see #43289 (comment)
|
||
Start by importing `math`, you will use it a lot in this project as it has useful methods like `math.radians`, `math.cos`, `math.sin` and others. | ||
|
||
Also create these variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a silly person and I spent about minute contemplating why copied from description:
PROJECTILE = "∙"
Is passing test, but when I write it:
PROJECTILE = '.'
or
PROJECTILE = "."
It doesn't.
Maybe from the start suggest in description copying all of them? Or move them to seed code?
|
||
The class variable `__slots__` has a special usage in Python classes. Declaring `__slots__` and assigning it a sequence of strings restricts the creation of attributes to those included in that sequence. Also, it prevents the creation of the `__dict__` special attribute and it allows for more efficient attribute access. | ||
|
||
You should use the `__slots__` variable inside the class to define which attributes the class has: assign to `__slots__` a tuple containing 3 strings, each equal to one of the attribute names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the `__slots__` variable inside the class to define which attributes the class has: assign to `__slots__` a tuple containing 3 strings, each equal to one of the attribute names. | |
You should use the `__slots__` variable inside the class to define which attributes the class has: assign to `__slots__` a tuple containing 3 strings, each equal to one of the attribute names defined in the `__init__`. |
|
||
You should use the methods `math.cos()` and `math.sin()` for the trigonometric functions and `math.sqrt()` to calculate the square root. Also you should know that \\(x^y\\) is written as `x ** y` in python. | ||
|
||
Remember that with name mangling you need to call the method as `_Projectile__calculate_displacement` if you want to test it: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that with name mangling you need to call the method as `_Projectile__calculate_displacement` if you want to test it: | |
Remember that with name mangling you need to call the method as `_Projectile__calculate_displacement` if you want to test, or use it from outside of the class: |
Create a method `__calculate_displacement`, which has only `self` as a parameter, and return the displacement of the projectile. | ||
|
||
Use the following formula to compute the projectile displacement: | ||
\\[ d = \frac{v^2 \cdot \cos(\theta) \cdot \left(\sin(\theta) + \sqrt{\sin^2(\theta) + \frac{2 \cdot g \cdot h}{v^2}}\right)}{g} \\] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\\[ d = \frac{v^2 \cdot \cos(\theta) \cdot \left(\sin(\theta) + \sqrt{\sin^2(\theta) + \frac{2 \cdot g \cdot h}{v^2}}\right)}{g} \\] | |
\\[ d = \frac{v^2 \cdot \cos\theta \cdot \left(\sin\theta + \sqrt{\sin^2\theta + \frac{2 \cdot g \cdot h}{v^2}}\right)}{g} \\] |
Parenthesis by sin
and cos
could be dropped to reduce the noise a little.
In which \\(d\\) is the displacement, \\(v\\) is the starting speed, \\(\theta\\) is the angle and \\(h\\) is the starting height of the projectile. | ||
For \\(g\\) you can use the `GRAVITATIONAL_ACCELERATION` variable. | ||
|
||
You should use the methods `math.cos()` and `math.sin()` for the trigonometric functions and `math.sqrt()` to calculate the square root. Also you should know that \\(x^y\\) is written as `x ** y` in python. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x_max = max(rounded_coords, key=lambda i: i[0])[0] | ||
y_max = max(rounded_coords, key=lambda j: j[1])[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If somebody would want to slightly introduce another module - operator
, this could be written without lambdas:
x_max = max(rounded_coords, key=lambda i: i[0])[0] | |
y_max = max(rounded_coords, key=lambda j: j[1])[1] | |
x_max = max(rounded_coords, key=operator.itemgetter(0))[0] | |
y_max = max(rounded_coords, key=operator.itemgetter(1))[1] |
|
||
# --description-- | ||
|
||
`matrix_list` is a list of lists, each element has an x,y coordinate. Use the list of coordinates in `rounded_coords` to change the elements in `matrix_list` at the coordinates in the list to the symbol in the `PROJECTILE` variable. Remember that a coordinates graph has the 0,0 in the bottom left corner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`matrix_list` is a list of lists, each element has an x,y coordinate. Use the list of coordinates in `rounded_coords` to change the elements in `matrix_list` at the coordinates in the list to the symbol in the `PROJECTILE` variable. Remember that a coordinates graph has the 0,0 in the bottom left corner. | |
`matrix_list` is a list of lists, each element has an (x, y) coordinate. Use the list of coordinates in `rounded_coords` to change the elements in `matrix_list` at the coordinates in the list to the symbol in the `PROJECTILE` variable. Remember that a coordinates graph has the (0, 0) in the bottom left corner. |
print(ball) | ||
coordinates = ball.calculate_all_coordinates() | ||
graph = Graph(coordinates) | ||
print(graph.create_trajectory()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't very readable in next steps, which might make it harder to get the correct results.
Maybe another step could be added to change it for couple steps?:
for row in graph.create_trajectory()
print(row)
```py | ||
[ | ||
"⊣ ∙ ", | ||
"⊣ ∙∙∙ ∙∙∙ ", | ||
"⊣ ∙ ∙ ", | ||
"⊣∙ ∙ ", | ||
"⊣ ∙ ", | ||
"⊣ ∙", | ||
"⊣ ", | ||
" ⊤⊤⊤⊤⊤⊤⊤⊤⊤⊤⊤⊤⊤", | ||
] | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just me, or this is not fully looking like it should?
Are the special characters messing up mono-spacing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are messing up the mono-spacing, let me see if I find a different character...
The method `create_trajectory` should return `graph`. | ||
|
||
```js | ||
({ | ||
test: () => runPython(` | ||
assert _Node(_code).find_class('Graph').find_function('create_trajectory').has_return('graph'), "return graph missing" | ||
`) | ||
}) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the exact value from function is tested (next hint) I think it's fine to not check how the returned thing is named in function. This likely apply to couple other steps.
Checklist:
main
branch of freeCodeCamp.Closes #XXXXX