dsba-python1-alpha 0.1.0__py3-none-any.whl

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,14 @@
1
+ """
2
+ dsba-python1-alpha
3
+ ──────────────────
4
+ Auto-checkers for the DSBA Python for Data Science course.
5
+
6
+ Quick start:
7
+ from dsba_checkers.workshops.w14_scipy import q1, q2, q3, q4, q5, q6, q7
8
+ q1.check(mean_charges, median_charges, skewness_charges, n_outliers)
9
+ q1.hint()
10
+ q1.solution()
11
+ """
12
+
13
+ __version__ = "0.1.0"
14
+ __author__ = "DSBA Python Course"
@@ -0,0 +1,56 @@
1
+ """Base class for all DSBA task checkers."""
2
+
3
+
4
+ class Task:
5
+ _hint = "No hint available for this task."
6
+ _solution = "No solution available for this task."
7
+ _max_attempts_before_solution = 3
8
+
9
+ def __init__(self):
10
+ self._attempts = 0
11
+
12
+ def check(self, *args, **kwargs):
13
+ self._attempts += 1
14
+ try:
15
+ result = self._check(*args, **kwargs)
16
+ except AssertionError as e:
17
+ self._print_wrong(str(e))
18
+ self._maybe_show_solution()
19
+ return
20
+ except TypeError as e:
21
+ print(f" ✗ Wrong argument types — did you pass the right variables?\n {e}")
22
+ return
23
+ except Exception as e:
24
+ print(f" ✗ Unexpected error:\n {type(e).__name__}: {e}")
25
+ return
26
+ if result is True or result is None:
27
+ self._print_correct()
28
+ else:
29
+ self._print_wrong(result if isinstance(result, str) else "")
30
+ self._maybe_show_solution()
31
+
32
+ def hint(self):
33
+ print(f"\n 💡 Hint:\n {self._hint}\n")
34
+
35
+ def solution(self):
36
+ print(f"\n 📋 Solution:\n{self._solution}\n")
37
+
38
+ def _check(self, *args, **kwargs):
39
+ raise NotImplementedError
40
+
41
+ def _print_correct(self):
42
+ print(" ✓ Correct!\n")
43
+
44
+ def _print_wrong(self, msg=""):
45
+ print(f" ✗ Not quite. {msg}\n" if msg else " ✗ Not quite. Check your logic and try again.\n")
46
+
47
+ def _maybe_show_solution(self):
48
+ if self._attempts >= self._max_attempts_before_solution:
49
+ print(f" (You've made {self._attempts} attempts — showing the solution.)")
50
+ self.solution()
51
+
52
+ @staticmethod
53
+ def _approx_equal(a, b, tol=0.01):
54
+ if b == 0:
55
+ return abs(a) < tol
56
+ return abs(a - b) / abs(b) < tol
@@ -0,0 +1 @@
1
+ # data sub-package — contains bundled CSV datasets