Skip to content

OLD functions concept exercise #2353

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

Closed
BethanyG opened this issue Feb 16, 2021 · 10 comments
Closed

OLD functions concept exercise #2353

BethanyG opened this issue Feb 16, 2021 · 10 comments
Assignees

Comments

@BethanyG
Copy link
Member

BethanyG commented Feb 16, 2021

This issue describes how to implement the functions concept and concept exercise for the Python track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Goal

This functions concept + concept exercise is meant to teach a deeper understanding and use of functions in Python. It should also explain how Python treats/views functions (as callable objects).

Learning Objectives

In Scope
  • Understand more about Python scopes and namespaces
    • understand the difference between the global and nonlocal keywords and when to use them
  • Get familiar with the special attributes of Python functions
  • Get familiar with best practices when using return, and the difference between explicit and implicit return
    • functions without an explicit return will return the singleton object None
  • Understand what is meant by "functions are first class objects in Python".
    • understand that functions are objects in Python, and that they have types
    • understand that functions can be assigned to variables, used in expressions, and stored in various data structures such as dicts or lists
    • create functons that are assigned to variables, used in expressions, and stored in different data structures.
    • understand and create functions that are/can be nested inside one another
  • Understand that Python considers a function a form of callable object.
  • Understand that a user-defined function object is created by a function definition.
Out of scope
  • named parameters (these can be touched on if needed)
  • default parameters (these can be touched on, if needed)
  • arbitrary parameters
  • *args & **kwargs
  • keyword-only arguments
  • / and * for requiring parameter types
  • functions-as-arguments (this can be mentioned, but shouldn't be required for the exercise)
  • functions-as-returns(_this can be mentioned, but will be covered in-depth in higher-order functions)
  • closures (these will be covered in a different exercise)
  • decorators (these will be covered in a different exercise)
  • functools.wraps (this is used mostly for decorators)
  • functools (this will get its own exercise)
  • comprehensions
  • generators
  • lambda, anonymous functions (these will be covered in a different exercise)
  • recursion

Concepts

  • callable objects
  • first-class functions
  • global
  • nested functions
  • nonlocal
  • return, implicit return, explicit return
  • scope
  • special function attributes

Prerequisites

Proposed Prerequisites

These are the concepts/concept exercises the student needs to complete/understand before solving this concept exercise. Since functions is a a bit of a "meta" topic, these can be adjusted to fit the parameters of the exercise, if needed.

  • basics
  • bools
  • comparisons
  • lists
  • list-methods
  • loops
  • numbers
  • strings
  • string-methods

Resources to Refer To

Links to resources

Concept Files to Be Created

Please see the following for more details on these files: concepts

  • links.json

    For more information, see concept links file

    • The same resources listed in this issue can be used as a starting point for the concepts/links.json file, if it doesn't already exist.
    • If there are particularly good/interesting information sources for this concept that extend or supplement the concept exercise material & the resources already listed -- please add them to the links.json document.
  • Concept about.md

    For more information, see Concept about.md

    • This file provides information about this concept for a student who has completed the corresponding concept exercise. It is intended as a reference for continued learning.
  • Concept introduction.md

    For more information, see Concept introduction.md

    • This can also be a summary/paraphrase of the about.md document listed above, and will provide a brief introduction of the concept for a student who has not yet completed the associated concept or practice exercises. It should contain a good summation of the concept, but not go into lots of detail.

Exercise Files to Be Created

  • Exercise introduction.md

    For more information, see Exercise introduction.md

    • This should also summarize/paraphrase the above concept documents (either the about or the introduction), and can copy the concept introduction verbatim. But the summary does need to have enough information and examples for the student to complete all the tasks outlined for this concept exercise.
  • Exercise instructions.md

    For more information, see instructions.md

    Instructions for an exercise usually center on a story that sets up the code challenge to be solved. You can create your own story, or fork one from the ones listed here. Please make sure to give credit to the original authors if you use a story or fork an exercise.

  • Exercise Exemplar Solution

    For more information, see exemplar implementation.

    This file should not use syntax or datas structures not introduced in this exercise or in this exercise's prerequisites. It will be used as an "ideal" solution for the challenge, so make sure it conforms to PEP8 and other formatting conventions, and does not use single letter variable names. It should also include proper module and function-level docstrings. However, it should NOT include typehinting or type aliases.

  • Exercise Stub for Implementation

    For more information, see stub implementation.

    This file should provide the expected function names imported for testing, and optionally TODO comments and or docstrings to aid the student in their implementation. TODOs and docstrings are not required.

  • Exercise Test Files

    For more information, see Tests.
    Additionally, please note that Python associates exercise tasks to tests via a Pytest Marker, and uses unittest subtests as a form of test paramaterization. See the test file for Little Sisters Vocab for examples of how these techniques work.

  • Exercise Hints

    For more information on writing hints see hints.md

    • Hints should provide enough information to get most students "un-stuck" and moving toward a solution. They should not provide a student with a direct solution.
    • You can refer to one or more of the resources linked in this issue above, or analogous resources from a trusted source. We prefer using links within the Python Docs as the primary go-to, but other resources listed above are also good. Please try to avoid paid or subscription-based links if possible.
  • Exercise Metadata Files Under .meta/config.json

    For more information on exercise .meta/ files and formatting, see concept exercise metadata files

    • .meta/config.json - see this link for the fields and formatting of this file.
    • .meta/design.md - see this link for the formatting of this file. Please use the Goal, Learning Objectives,Concepts, Prerequisites and , Out of Scope sections from this issue.

Exercise Metadata - Track

For more information on concept exercises and formatting for the Python track config.json , please see config.json. The track config.json file can be found in the root of the Python repo.

You can use the below for the exercise UUID. You can also generate a new one via exercism configlet, uuidgenerator.net, or any other favorite method. The UUID must be a valid V4 UUID.

  • Exercise UUID : ``
  • concepts should be filled in from the Concepts section in this issue
  • prerequisites should be filled in from the Prerequisites section in this issue

Implementation Notes

  • As a reminder, code in the .meta/examplar.py file should only use syntax & concepts introduced in this exercise or one of its prerequisite exercises. We run all our examplar.py files through PyLint, but do not strictly require module docstrings. We do require function docstrings similar to PEP257. See this concept exercise exemplar.py for an example.

  • Please do not use comprehensions, generator expressions, or other syntax not previously covered either in the introduction to this exercise, or to one of its prerequisites. Please also follow PEP8 guidelines.

  • In General, tests should be written using unittest.TestCase and the test file should be named <EXERCISE-NAME>_test.py.

    • All asserts should contain a "user friendly" failure message (these will display on the webiste to students, so be as clear as you can).
    • We use a PyTest custom mark to link test cases to exercise task numbers.
    • We also use unittest.subtest to parameterize test input where/when needed.
      Here is an example testfile that shows all three of these in action.
  • While we do use PyTest as our test runner and for some implementation tests, please check with a maintainer before using a PyTest-specific test method, fixture, or feature.

  • Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue, or contact one of the maintainers on our Slack channel.

@BethanyG BethanyG added this to the New V3 Concept Exercises milestone Mar 31, 2021
@BethanyG BethanyG modified the milestones: New V3 Concept Exercises, V3 Concept Exercises for Beta May 21, 2021
@BethanyG BethanyG added x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:size/large Large amount of work help wanted We'd like your help with this. new exercise ✨ x:knowledge/advanced Comprehensive Exercism knowledge required and removed x:knowledge/intermediate Quite a bit of Exercism knowledge required labels Jun 15, 2021
@BethanyG BethanyG changed the title [V3] Implement New Concept Exercise: functions [ New Concept Exercise] : functions Jun 16, 2021
@BethanyG BethanyG changed the title [ New Concept Exercise] : functions [New Concept Exercise] : functions Jun 16, 2021
@BethanyG BethanyG added x:knowledge/intermediate Quite a bit of Exercism knowledge required and removed x:knowledge/advanced Comprehensive Exercism knowledge required labels Jun 16, 2021
@BethanyG BethanyG added x:knowledge/advanced Comprehensive Exercism knowledge required and removed x:knowledge/intermediate Quite a bit of Exercism knowledge required labels Aug 12, 2021
@mukeshgurpude
Copy link
Contributor

Hello @BethanyG, let me know if I can work on this.

@BethanyG
Copy link
Member Author

BethanyG commented Sep 9, 2021

@mukeshgurpude YES! And many thanks for stepping up and taking it on! 🎉

Bear with me: the links at the top for documentation should all be up-to-date, but the links down below in the detail are old, and need updating. I will do that here shortly. Please (as always) let me know if you have any questions or issues or need help.

Also - gentle reminder to make sure you update and pull in all changes from upstream before getting a start. I recommend rebasing main after doing a fetch, so that any introduced changes are inserted in order. And -- depending on how you want to organize, you can do one PR for the concept (functions) and one for the concept exercise. But that's up to you. 😄

@BethanyG BethanyG added claimed 🐾 For new exercises being written by contributors and maintainers. x:status/claimed Someone is working on this issue and removed help wanted We'd like your help with this. labels Sep 9, 2021
@J08K
Copy link
Member

J08K commented Sep 22, 2021

Heya @mukeshgurpude,
how's it going with this concept exercise? Haven't heard anything in a few days, so I'm just checking in!

Do you need me to look at some drafts of the exercise for you? Or do you have any questions? Feel free to ping me here, or submit a draft PR that we can look at and ping me there. You can also always ping me on slack!

Good luck and happy coding! 🐍

@mukeshgurpude
Copy link
Contributor

Hello @J08K,
actually, I'm in the middle of my examinations. I'll be working on this just after that.
I'll open a draft PR with my first edit only..

@J08K
Copy link
Member

J08K commented Sep 22, 2021

Cool, focus on your exams first ofcourse! Goodluck. Tag me in your draft PR when you make it. :)

@mukeshgurpude
Copy link
Contributor

mukeshgurpude commented Oct 3, 2021

Hello, @BethanyG, @J08K
While #2623 is under review, I need some suggestions for the real world example for this exercise.
I initially thought of something as interest-calculator, which will just calculate the simple and compound interest, but in this it wasn't possible to show reusability🤔.

@BethanyG BethanyG assigned bobahop and unassigned mukeshgurpude May 26, 2022
@exercism exercism deleted a comment from github-actions bot May 26, 2022
@BethanyG BethanyG added the x:rep/large Large amount of reputation label May 26, 2022
@BethanyG BethanyG removed this from the V3 Concept Exercises for Beta milestone Jun 14, 2022
@bobahop
Copy link
Member

bobahop commented Jun 16, 2022

@BethanyG Any idea for what you want to see for the exercise here? Any analogous exercise you might want transcribed from another track? I can start looking at the tracks I'm familiar with. Nothing comes to mind right now.

@bobahop
Copy link
Member

bobahop commented Jun 16, 2022

Rust uses lasagna, but we use lasagna for basics. Go uses Booking Up For Beauty, but that also makes significant use of string formatting, so it might not be as focused for functions as desired.

@BethanyG
Copy link
Member Author

@bobahop there are a few things to note here:

  1. This issue has very outdated links and descriptions and it also pings the attached users every time we make a comment, so I think its best if we close it in favor of a new issue using the new template. I will do that shortly.

  2. I have a strong preference for original stories/exercises, unless the port/concept is an almost 1-to-1, as was the case with bools. That isn't to say that porting is verboten, but I'd much rather have a purpose-built exercise than a shoehorned one. We have had trouble in the past with contributors trying to port something and then getting stalled because they were not able to transfer some core piece to Python.

  3. As I've mentioned, this exercise is quite far "down" the exercise tree. It should not be considered an exercise on how to make functions in Python, but rather as a setup to both higher order functions and related concepts. So we should try to think of something that deepens a student's understanding/use of functions, and exercises some of the features unique to Python. Otherwise, this may as well be a practice exercise or a concept-only topic.

I'll add some thoughts/ideas to the new issue.

@BethanyG BethanyG removed x:action/create Work on something from scratch x:knowledge/advanced Comprehensive Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:status/claimed Someone is working on this issue x:size/large Large amount of work claimed 🐾 For new exercises being written by contributors and maintainers. new exercise ✨ x:rep/large Large amount of reputation labels Jun 16, 2022
@BethanyG BethanyG changed the title [New Concept Exercise] : functions OLD functions concept exercise Jun 16, 2022
@BethanyG
Copy link
Member Author

Closing this in favor of #3121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants