Skip to content
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

In 16-writing-functions, print_date example needs revising #538

Closed
ognancy4life opened this issue Apr 9, 2021 · 3 comments · Fixed by #546
Closed

In 16-writing-functions, print_date example needs revising #538

ognancy4life opened this issue Apr 9, 2021 · 3 comments · Fixed by #546
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson

Comments

@ognancy4life
Copy link

In lesson 16: Writing Functions, there is a question regarding "Order of Operations" using the print_date function. This is a good question, but because print_date has already been defined earlier in the lesson, the students will not get the desired error. I recommend using a different example function here to teach order of operations. Thank you!

@alee
Copy link
Member

alee commented Apr 9, 2021

@alee alee added good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson labels Apr 9, 2021
@AlexT97
Copy link

AlexT97 commented Apr 24, 2021

One suggestion with Order of Operations, I think it might be clearer for students looking through this to have multiple examples to work with. The print_date is probably okay to work with but I would recommend something a bit shorter to go alongside. One thing that might be useful would be to have another full example of a function definition, like @ognancy4life suggested, but using mathematical expressions. This way, it's short, with hopefully pretty transparent functionality and that way, it doesn't really get in the way of the bigger issue of order of operations in a Python script. In addition, an example like this might make explaining exactly what went wrong and why a lot easier. That could even be a good lead-in to the print_date order of operations example. A good example for a simpler order of operations example might be something like this:

basic_math(1,2,3)
def basic_math(x, y, z):
return (x + (y * z))

  • With corrected spacing of course! I'm still kind of new to GitHub's code block notation on comments!
  • This would return 7 for basic_math(1,2,3) but 5 for basic_math(3,2,1) so if you wanted, it could also be used for something like showing how order of argument inputs to a function can be important as well.
  • In addition, if you want to show point (3) about return statements, you could simply assign (x + (y * z)) to a variable like result and then not return it. This would result in the same issue as shown in (3).

@perlman
Copy link
Contributor

perlman commented Apr 28, 2021

My PR (#546) was an effort to change this with the minimal edits.

The example @AlexT97 provides would certainly work, and might be superior in that there would be less to type in if a student tries to do so. I guess the question is which additional concepts would be less confusing: using parentheses to order mathematical operations, or string building?

I don't know. :)

@alee alee linked a pull request Jun 4, 2021 that will close this issue
@alee alee closed this as completed in #546 Jun 4, 2021
alee pushed a commit that referenced this issue Jun 4, 2021
As suggested in #538, the function print_date was previously defined.
This updated question will use print_time instead.
zkamvar pushed a commit that referenced this issue May 2, 2023
As suggested in #538, the function print_date was previously defined.
This updated question will use print_time instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants