exercism / python

Exercism exercises in Python.
https://exercism.org/tracks/python
MIT License
1.88k stars 1.26k forks source link

[New Concept Exercise] : function-arguments #2354

Closed BethanyG closed 9 months ago

BethanyG commented 3 years ago

This issue describes how to implement the function-arguments 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 concept exercise is meant to teach a deeper understanding/use of function-arguments in python.

Learning objectives

Out of scope

Concepts

Prerequisites

These are the concepts/concept exercises the student needs to complete/understand before solving this concept exercise.

Resources to refer to

Concept Description

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

Test-runner

No changes required to the Python Test Runner at this time.

Representer

No changes required to the Python Representer at this time.

Analyzer

No changes required to the Python Analyzer at this time.

Exercise Metadata - Track

For more information on concept exercises and formatting for the Python track config.json , please see concept exercise metadata. 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 Metadata Files Under .meta/config.json

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

Implementation Notes

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.

asrvd commented 2 years ago

@BethanyG I want to work on this issue, but if I do work on it, this would be my first contribution here, and I'm not really sure about how to build those exercises, I understood the making concept and documentation part though.

BethanyG commented 2 years ago

Hi @asheeeshh 👋🏽

I am delighted you want to help! Don't worry about it being your first contribution, or not knowing how to "build" an exercise -- I and the other maintainers and volunteers for the Python track are more than happy to help you through the process. 😄

I will assign this issue to you and remove the help wanted label.
Next -- I will be back with some links and examples for you (it will take me a little time to assemble them). I'm happy to answer any questions you might have about the process - and can even collaborate with you in your repo or mine prior to PR-ing here, if that is more comfortable for you.

Additionally, if you are on our Exercism Slack, I am happy to also chat and collaborate there.

asrvd commented 2 years ago

Alright, I'll try to find some ideas for the exercise too, once something hits me, I'll start working on it.

BethanyG commented 2 years ago

If coming up with a story seems intimidating, we do have a story listing of stories that have been used for exercises across language tracks. If any of those look interesting to you, you can adapt one of them to this exercise. 😄

BethanyG commented 2 years ago

One thought would be to also go back over the concept exercises we currently have, and see if any of those stories/problems could be extended or adapted for using as a function-argumenst exercise. No need to reinvent the wheel.

An example might be Lasagna Master, which is from the list above, but is also an extension of Guidos Gorgeous Lasagna -- which is the current Python basics concept exercise.

BethanyG commented 2 years ago

So -- for links/detail:

This is a concept exercise - which is intended to focus the student on a small set of topics or concepts from Python. So, generally, we assume the student knows how to program -- just not in Python -- but only has the bits of Python knowledge that have already been covered in the exercise prerequisites.

So for function-arguments, you have a healthy amount of tools you can use in the exemplar.py file, and can assume for the exercise. But you'd want to stay away from things like classes, comprehensions, decorators, or regex.

Exercises should be as engaging as we can make them, given the topic -- but also not too long. A seasoned programmer shouldn't need more than 5-15 minutes to solve one.

Here are some examples of exercises and concept write-ups from both Python and other language tracks. At each link, you can see how the exercise/concept is organized, and what the different documents look like.

Python : Little Sisters Essay (Exercism Site), Little Sisters Essay (GitHub ) & string-methods concept (GitHub) Elixir: Pacman Rules (Exercism Site)& Pacman Rules (GitHub) & Booleans concept C#: Phone Number Analysis (Exercism Site), Phone Number Analysis (GitHub) & tuples concept (GitHub)

And as a reminder:

Tracks - building Concept Exercises - general Concept Exercises - building Contributors Pull Request Guide Python Track Contributing Guide

And please reach out with any questions or issues. 👋🏽

asrvd commented 2 years ago

@BethanyG I took a little inspiration from the lasagna exercise and was able to come up with this bake the cake exercise, where the learners would create different functions to make the cake, bake it, and the calculate it's price.

The make_cake( ) function can take in parameters like ingredients and amount of ingredients, so we can implement the *args / **kwargs method here.

The bake_cake( ) function can take parameters like temperature, time, weight where we can implement default/named parameters.

The calculate_price( ) function can take paramters like the flavor and weight where we can implement any other concept that's been left out like positional parameters.

Please have a look, and let me know if I can make any changes to make it better.

BethanyG commented 2 years ago

@asheeeshh

I took a little inspiration from the lasagna exercise and was able to come up with this bake the cake exercise, where the learners would create different functions to make the cake, bake it, and the calculate it's price.

I love it! We could name it Himari's Cake Shop 😄 . And have pricing that is based on number of ingredients or types ... There are so many parameter variants, I'm sure we can find cake permutations for all of them. 😉

One quick idea: we could use calculate_price( ) with default arguments for a "base" cake, then use **kwargs with "price markups" for additional ingredients/layers for pricing.... 🤔


Would you like to open a draft PR with maybe some functions or instructions stubbed out - and we can start building from there? Whichever entry point feels good for you to start on. Also happy to collaborate in a private repo with you, if that feels better.

I can also provide empty files and exercise/concept directories as a starting place -- if that helps things. Just let me know what you need. I think you are definitely headed in the right direction! 🌈 🎉

asrvd commented 2 years ago

Yes, I would start working on the fork, and open a pr once I'm done with the basic structure of exercise.

But first I want to know about the flow of exercise, like as far as I know each exercise is divided into tasks, I want to know about the alignment of tasks based on concepts, like keeping the first task **arg and **kwarg may not be a good idea, or I'm wrong?

I would like to know about how you want the exercise tasks to be aligned. Meanwhile I would start working with writing the code. 😀

BethanyG commented 2 years ago

Ah! Yes -- good questions. 😄

So - for this, I think the general "attack" would be to build from the most familiar to the least familiar/most complicated:

And once the core use cases have been covered, the "weird" or "strange" cases:

And usually, each topic is a task, so here maybe we'd do each topic/task as a function that needs to be written? And maybe one of the later functions might be a combination of all the different parameters that then needs to be annotated with the / and *?? Whatever works with the story without seeming too contrived. I would think no more than 7-8 functions tops -- less if you can manage it, since these aren't meant to be really long exercises.

We also want to be careful to not introduce anything that's not in this exercise itself, or in the prerequisite exercises.

And generally, I would introduce the topics in the same order as the exercise has them when I'm writing the concept documents (_the introduction.md, the concept_introduction.md, and the about.md_).

I typically write the instructions, hints, and tests last, since I often need working code and examples to really fill in detail for them.

Does that sound good? Let me know. 😄


edited to add:

We are assuming that a given student is not new to programming. But that they are new to Python. We are also assuming that the student has worked through the previous exercises in the syllabus tree.

So a student will have had experience with positional parameters -- and may or may not have had some exposure to named and default parameters. They will in all likelihood not be familiar at all with *args and **kwargs or the rest of the weirdness.

All that being said - we do want code examples in the support documents that are clear and easily pasted into the REPL, so students can play with them.

You can review structure and layout of files here: concept exercises and concepts

asrvd commented 2 years ago

Got it, I'll start working on it right away and make a PR soon, thank you :)

asrvd commented 2 years ago

Just wanted to let you know, it would take some more time for me to finish this, I have some exams next month so I need to study.

BethanyG commented 2 years ago

Thanks for the note @asheeeshh. 😄

good luck on the exams! We'll keep you assigned to this issue, and you can work on it as you have time.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as abandoned 🏚 because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as abandoned 🏚 because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

BethanyG commented 2 years ago

Since the concept for this is written an merged, and @asheeeshh has expressed interest in continuing with the concept exercise, I am going to re-assign them. 😄

asrvd commented 2 years ago

update: I have my exams on 25th of june so I'll start working on this issue again from 26th hopefully :)

BethanyG commented 2 years ago

@asrvd - just checking in -- are you still interested in working on this? Just let me know...thanks!

github-actions[bot] commented 2 years ago

This issue has been automatically marked as abandoned 🏚 because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

asrvd commented 2 years ago

hey @BethanyG sorry for the late response, i'm still on it, will try to finish this by the end of month, would need a lot of help on the PR though

edit: I dont think I would be able to work on this, apparently my college is starting and so I need to focus there, sorry for this, would love to contribute again in future once I have a good amount of time in hand