sommatoria 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: sommatoria
3
+ Version: 0.1.0
4
+ Summary: Libreria Python per il calcolo delle sommatorie
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sommatoria"
7
+ version = "0.1.0"
8
+ description = "Libreria Python per il calcolo delle sommatorie"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+
12
+ [tool.setuptools.packages.find]
13
+ include = ["sommatoria*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .series import Sommatoria
2
+
3
+ __all__ = ["Sommatoria"]
@@ -0,0 +1,25 @@
1
+ class Sommatoria:
2
+
3
+ def __init__(self, n):
4
+ if not isinstance(n, int) or isinstance(n, bool):
5
+ raise TypeError("n deve essere un intero")
6
+
7
+ if n < 0:
8
+ raise ValueError("n deve essere maggiore o uguale a zero")
9
+
10
+ self.n = n
11
+
12
+ def somma_naturali(self):
13
+ return sum(range(1, self.n + 1))
14
+
15
+ def somma_quadrati(self):
16
+ return sum(i**2 for i in range(1, self.n + 1))
17
+
18
+ def somma_cubi(self):
19
+ return sum(i**3 for i in range(1, self.n + 1))
20
+
21
+ def sommatoria_generale(self, funzione):
22
+ return sum(funzione(i) for i in range(1, self.n + 1))
23
+
24
+ def __str__(self):
25
+ return f"Sommatoria fino a {self.n}"
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: sommatoria
3
+ Version: 0.1.0
4
+ Summary: Libreria Python per il calcolo delle sommatorie
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ sommatoria/__init__.py
4
+ sommatoria/series.py
5
+ sommatoria.egg-info/PKG-INFO
6
+ sommatoria.egg-info/SOURCES.txt
7
+ sommatoria.egg-info/dependency_links.txt
8
+ sommatoria.egg-info/top_level.txt
9
+ tests/test_series.py
@@ -0,0 +1 @@
1
+ sommatoria
@@ -0,0 +1,27 @@
1
+ import unittest
2
+ from sommatoria import Sommatoria
3
+
4
+
5
+ class TestSommatoria(unittest.TestCase):
6
+
7
+ def test_somma_naturali(self):
8
+ s = Sommatoria(5)
9
+ self.assertEqual(s.somma_naturali(), 15)
10
+
11
+ def test_somma_quadrati(self):
12
+ s = Sommatoria(5)
13
+ self.assertEqual(s.somma_quadrati(), 55)
14
+
15
+ def test_somma_cubi(self):
16
+ s = Sommatoria(5)
17
+ self.assertEqual(s.somma_cubi(), 225)
18
+
19
+ def test_sommatoria_generale(self):
20
+ s = Sommatoria(5)
21
+ self.assertEqual(
22
+ s.sommatoria_generale(lambda x: x * 2), 30
23
+ )
24
+
25
+
26
+ if __name__ == "__main__":
27
+ unittest.main()