diff --git a/exercises/concept/meltdown-mitigation/.docs/hints.md b/exercises/concept/meltdown-mitigation/.docs/hints.md index 510b8bd4..e500bb4d 100644 --- a/exercises/concept/meltdown-mitigation/.docs/hints.md +++ b/exercises/concept/meltdown-mitigation/.docs/hints.md @@ -8,7 +8,7 @@ ## 1. Check for criticality -- Comparison operators and boolean operations can be combined and used with conditionals. +- Comparison operators ([comparisons][comparisons review]) and boolean operations ([concept:python/bools]()) can be combined and used with conditionals. - Conditional expressions must evaluate to `True` or `False`. - `else` can be used for a code block that will execute when all conditional tests return `False`. @@ -16,9 +16,9 @@ >>> item = 'blue' >>> item_2 = 'green' - >>> if len(item) >=3 and len(item_2) < 5: + >>> if len(item) >= 3 and len(item_2) < 5: print('Both pass the test!') - elif len(item) >=3 or len(item_2) < 5: + elif len(item) >= 3 or len(item_2) < 5: print('One passes the test!') else: print('None pass the test!') @@ -29,20 +29,20 @@ ## 2. Determine the Power output range - Comparison operators can be combined and used with conditionals. -- Any number of `elif` statements can be used as "branches". +- Any number of `elif` statements can be used as decision "branches". - Each "branch" can have a separate `return` ## 3. Fail Safe Mechanism - Comparison operators can be combined and used with conditionals. -- Any number of `elif` statements can be used as "branches". +- Any number of `elif` statements can be used as decision "branches". - Each "branch" can have a separate `return` -[python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm [boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not +[comparisons review]: https://www.learnpython.dev/02-introduction-to-python/090-boolean-logic/20-comparisons/ [comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons -[python booleans]: https://realpython.com/python-boolean/ -[real python conditionals]: https://realpython.com/python-conditional-statements/ [control flow tools]: https://docs.python.org/3/tutorial/controlflow.html - +[python booleans]: https://realpython.com/python-boolean/ +[python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm +[real python conditionals]: https://realpython.com/python-conditional-statements/ diff --git a/exercises/concept/meltdown-mitigation/.docs/introduction.md b/exercises/concept/meltdown-mitigation/.docs/introduction.md index da5ebbae..fe9fff4d 100644 --- a/exercises/concept/meltdown-mitigation/.docs/introduction.md +++ b/exercises/concept/meltdown-mitigation/.docs/introduction.md @@ -3,9 +3,9 @@ In Python, [`if`][if statement], `elif` (_a contraction of 'else and if'_) and `else` statements are used to [control the flow][control flow tools] of execution and make decisions in a program. Unlike many other programming languages, Python versions 3.9 and below do not offer a formal case-switch statement, instead using multiple `elif` statements to serve a similar purpose. -Python 3.10 introduces a variant case-switch statement called `pattern matching`, which will be covered separately in another concept. +Python 3.10 introduces a variant case-switch statement called `structural pattern matching`, which will be covered separately in another concept. -Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` directly, or by evaluating ["truthy" or "falsy"][truth value testing]. +Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` type directly, or by evaluating as ["truthy" or "falsy"][truth value testing]. ```python x = 10 @@ -74,8 +74,8 @@ else: '13' ``` -[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement -[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools -[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing [boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not [comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons +[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools +[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement +[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing diff --git a/exercises/concept/meltdown-mitigation/.meta/design.md b/exercises/concept/meltdown-mitigation/.meta/design.md index cdc482c6..33ef7e3b 100644 --- a/exercises/concept/meltdown-mitigation/.meta/design.md +++ b/exercises/concept/meltdown-mitigation/.meta/design.md @@ -3,11 +3,11 @@ ## Goal -The goal of this exercise is to teach the student what is a `conditional` and how they are used in Python. +The goal of this exercise is to teach the student about `conditionals` and how they are used in Python. ## Learning objectives -- learn some general things about `control flow` in python +- learn some general things about `control flow` in Python - create a `conditional` structure to choose something, take a decision - use an `if...else` structure - use an `if..elif...else` structure diff --git a/exercises/concept/meltdown-mitigation/conditionals_test.py b/exercises/concept/meltdown-mitigation/conditionals_test.py index 9837c343..5e48ca32 100644 --- a/exercises/concept/meltdown-mitigation/conditionals_test.py +++ b/exercises/concept/meltdown-mitigation/conditionals_test.py @@ -30,8 +30,10 @@ class MeltdownMitigationTest(unittest.TestCase): # pylint: disable=assignment-from-no-return actual_result = is_criticality_balanced(temp, neutrons_emitted) - failure_message = (f'Expected {expected} but returned {actual_result} ' - f'with T={temp} and neutrons={neutrons_emitted}') + failure_message = (f'Called is_criticality_balanced({temp}, {neutrons_emitted}). ' + f' The function returned {actual_result}, ' + f'but the test expected {expected} as the return value.') + self.assertEqual(actual_result, expected, failure_message) @pytest.mark.task(taskno=2) @@ -52,8 +54,10 @@ class MeltdownMitigationTest(unittest.TestCase): # pylint: disable=assignment-from-no-return actual_result = reactor_efficiency(voltage, current, theoretical_max_power) - failure_message = (f'Expected {expected} but returned {actual_result} ' - f'with voltage={voltage}, current={current}, max_pow={theoretical_max_power}') + failure_message =(f'Called reactor_efficiency({voltage}, {current}, {theoretical_max_power}). ' + f'The function returned {actual_result}, ' + f'but the test expected {expected} as the return value.') + self.assertEqual(actual_result, expected, failure_message) @pytest.mark.task(taskno=3) @@ -71,6 +75,8 @@ class MeltdownMitigationTest(unittest.TestCase): # pylint: disable=assignment-from-no-return actual_result = fail_safe(temp, neutrons_per_second, threshold) - failure_message = (f'Expected {expected} but returned {actual_result} with T={temp}, ' - f'neutrons={neutrons_per_second}, threshold={threshold}') + failure_message = (f'Called fail_safe({temp}, {neutrons_per_second}, {threshold}). ' + f'The function returned {actual_result}, ' + f'but the test expected {expected} as the return value.') + self.assertEqual(actual_result, expected, failure_message)