Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,18 @@
"Algorithms"
]
},
{
"uuid": "bacb2184-025f-0980-38d6-34fb419e03a6d3d8b44",
"slug": "two-fer",
"core": false,
"unlocked_by": null,
"difficulty": 1,
"topics": [
"control-flow (if-else statements)",
"optional values",
"text formatting"
]
},
{
"uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd",
"slug": "accumulate",
Expand Down
29 changes: 29 additions & 0 deletions exercises/two-fer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Two-fer

`Two-fer` or `2-fer` is short for two for one. One for you and one for me.

```
"One for X, one for me."
```

When X is a name or "you".

If the given name is "Alice", the result should be "One for Alice, one for me."
If no name is given, the result should be "One for you, one for me."

### Submitting Exercises

Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.

For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.


For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).

## Source

This is an exercise to introduce users to basic programming constructs, just after hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
5 changes: 5 additions & 0 deletions exercises/two-fer/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def two_fer(name=""):
if not name.strip():
return "One for you, one for me."
else:
return "One for %s, one for me." % name
2 changes: 2 additions & 0 deletions exercises/two-fer/two_fer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def two_fer():
pass
18 changes: 18 additions & 0 deletions exercises/two-fer/two_fer_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import unittest

import two_fer


class Two_Fer_test(unittest.TestCase):
def test_empty(self):
self.assertEqual(two_fer.two_fer(), 'One for you, one for me.')

def test_eve(self):
self.assertEqual(two_fer.two_fer("Eve"), "One for Eve, one for me.")

def test_bob(self):
self.assertEqual(two_fer.two_fer("Bob"), "One for Bob, one for me.")


if __name__ == '__main__':
unittest.main()