File tree
Expand file treeCollapse file tree6 files changed
+32
-10
lines changed Expand file treeCollapse file tree6 files changed
+32
-10
lines changed Original file line number | Diff line number | Diff line change |
---|
|
15 | 15 | __pycache__/
|
16 | 16 | .pytest_cache/
|
17 | 17 |
|
18 |
| -!/.breathecode |
19 |
| -/.breathecode/** |
20 |
| -!/.breathecode/resets |
21 |
| -!/.breathecode/resets/** |
| 18 | +!/.learn |
| 19 | +/.learn/** |
| 20 | +!/.learn/resets |
| 21 | +!/.learn/resets/** |
Original file line number | Diff line number | Diff line change |
---|
|
3 | 3 | second_number = input("Second input")
|
4 | 4 | third_number = input("Third input")
|
5 | 5 | # print here the sum of three inputs
|
| 6 | + |
| 7 | +print(first_number+second_number) |
Original file line number | Diff line number | Diff line change |
---|
@@ -8,14 +8,23 @@ def test_use_print():
|
8 | 8 | regex = re.compile(r"print(\s)*\(")
|
9 | 9 | assert bool(regex.search(content)) == True
|
10 | 10 |
|
| 11 | +@pytest.mark.it('Almost there! But you need to convert the incoming input from string to integer') |
| 12 | +def test_convert_inputs(capsys, app): |
| 13 | + |
| 14 | +fake_input = ["2","3","4"] #fake input |
| 15 | +with mock.('builtins.input', lambda x: fake_input.pop()): |
| 16 | +app() |
| 17 | +captured = capsys.readouterr() |
| 18 | +assert captured.out != "432\n" |
| 19 | + |
11 | 20 | @pytest.mark.it('Sum all three input numbers and print on the console the result')
|
12 | 21 | def test_add_variables(capsys, app):
|
13 | 22 |
|
14 |
| -fake_input = [2,3,4] #fake input |
| 23 | +fake_input = ["2","3","4"] #fake input |
15 | 24 | with mock.('builtins.input', lambda x: fake_input.pop()):
|
16 |
| -app() |
17 |
| -captured = capsys.readouterr() |
18 |
| -assert captured.out == "9\n" |
| 25 | +app() |
| 26 | +captured = capsys.readouterr() |
| 27 | +assert captured.out == "9\n" |
19 | 28 |
|
20 | 29 |
|
21 | 30 |
|
|
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | # `21` Factorial
|
2 | 2 |
|
| 3 | +## 📝 Instructions |
| 4 | + |
3 | 5 | Write a program which can compute the factorial of a given numbers.
|
4 | 6 | The results should be printed in a comma-separated sequence on a single line.
|
5 | 7 | Suppose the following input is supplied to the program:
|
| 8 | + |
| 9 | +```bash |
6 | 10 | 8
|
| 11 | +``` |
| 12 | + |
7 | 13 | Then, the output should be:
|
| 14 | + |
| 15 | +```bash |
8 | 16 | 40320
|
| 17 | +``` |
| 18 | + |
| 19 | +## 💡Hints: |
9 | 20 |
|
10 |
| -Hints: |
11 | 21 | In case of input data being supplied to the question, it should be assumed to be a console input.
|
Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +# Your code here |
Original file line number | Diff line number | Diff line change |
---|
@@ -3,5 +3,5 @@ def fact(x):
|
3 | 3 | return 1
|
4 | 4 | return x * fact(x - 1)
|
5 | 5 |
|
6 |
| -x=int(raw_input()) |
| 6 | +x=int(input()) |
7 | 7 | print fact(x)
|
You can’t perform that action at this time.
0 commit comments