File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
📝 Instructions:
44

55
N students take K apples and distribute them among each other evenly. The remaining (the indivisible) part remains in the basket. How many apples will each single student get? How many apples will remain in the basket?
6-
The program reads the numbers N and K. It should print the two answers for the questions above.
6+
The program reads the numbers N and K. It should return the two answers for the questions above.
77

88
**Example input**
9-
* 6
10-
* 50
9+
* (6, 50)
1110

1211
**Example output**
13-
* 8
14-
* 2
12+
* (8, 2)
1513

1614
**Theory**
15+
Hint: You can return multiple parameters: return a, b
16+
1717
If you don't know how to start solving this assignment, please, review a theory for this lesson:
1818
https://snakify.org/lessons/print_input_numbers/
1919

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#Complete the function to print:
1+
#Complete the function to return:
22
#1) How many apples each single student will get.
33
#2) How many apples wil remain in the basket.
4-
#Hint: Import the math module
4+
#Hint: You can resolve this exercise either importing the math module or without it
55
def apple_sharing(n,k):
6-
6+
7+
return None
78

89

910

1011
#Print the two answer per the example output.
11-
apple_sharing(6,50)
12+
print(apple_sharing())
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
1-
import io
2-
import sys
3-
sys.stdout = buffer = io.StringIO()
4-
import app
5-
import math
6-
import pytest
1+
import io, sys, pytest, os, re, mock
72

8-
@pytest.mark.it('Print how many apples each student will get')
9-
def test_for_apples_for_student(capsys):
10-
app.apple_sharing(23,256)
11-
captured = capsys.readouterr()
3+
@pytest.mark.it('The function apple_sharing must exist')
4+
def test_for_functon_existence(capsys, app):
5+
assert callable(app.apple_sharing)
126

13-
test1 = captured.out.split("\n")
7+
@pytest.mark.it('The function apple_sharing must return the correct output')
8+
def test_for_file_output(capsys, app):
9+
assert app.apple_sharing(10, 54) == (54//10, 54%10)
1410

15-
if test1[0] == "11":
16-
assert True
17-
else:
18-
assert False
1911

20-
@pytest.mark.it('Print how many apples will remain in the basket')
21-
def test_for_remaining_apples(capsys):
22-
app.apple_sharing(23,256)
23-
captured = capsys.readouterr()
24-
25-
test1 = captured.out.split("\n")
26-
27-
if test1[1] == "3":
28-
assert True
29-
else:
30-
assert False

0 commit comments

Comments
 (0)