Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/concept/currency-exchange/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
## 4. Calculate number of bills

- You need to divide `budget` into `denomination`.
- You need to use type casting _int_ to get exact number of bill.
- You need to use type casting to _int_ to get the exact number of bills.
- To remove decimal places from a `float`, you can convert it to `int`.

**Note:** The `//` operator also does floor division. But, if the operand has `float`, the result is still `float`.

## 5. Calculate exchangeable value

- You need to calculate `spread` percent of `exchange_rate` using multiplication operator and add it to `exchange_rate` to get the exchanged currency.
- Actual rate need to be computed! add exchange rate and exchange fee.
- The actual rate needs to be computed. Remember to add exchange rate and exchange fee.
- You can get exchanged money affected by commission by using divide operation and type casting _int_.
2 changes: 1 addition & 1 deletion exercises/concept/meltdown-mitigation/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- Comparison operators and boolean operations 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 a conditional test returns `False`.
- `else` can be used for a code block that will execute when all conditional tests return `False`.

```python
>>> item = 'blue'
Expand Down
14 changes: 7 additions & 7 deletions exercises/concept/meltdown-mitigation/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ In this exercise, we'll develop a simple control system for a nuclear reactor.
For a reactor to produce the power it must be in a state of _criticality_.
If the reactor is in a state less than criticality, it can become damaged.
If the reactor state goes beyond criticality, it can overload and result in a meltdown.
We want to mitigte the chances of meltdown and correctly manage reactor state.
We want to mitigate the chances of meltdown and correctly manage reactor state.

The following three tasks are all related to writing code for maintaining ideal reactor state.

Expand All @@ -14,9 +14,9 @@ The following three tasks are all related to writing code for maintaining ideal
The first thing a control system has to do is check if the reactor is balanced in criticality.
A reactor is said to be critical if it satisfies the following conditions:

- The temperature less than 800.
- The number of neutrons emitted per second greater than 500.
- The product of temperature and neutrons emitted per second less than 500000.
- The temperature is less than 800.
- The number of neutrons emitted per second is greater than 500.
- The product of temperature and neutrons emitted per second is less than 500000.

Implement the function `is_criticality_balanced()` that takes `temperature` and `neutrons_emitted` as parameters, and returns `True` if the criticality conditions are met, `False` if not.

Expand All @@ -35,8 +35,8 @@ Efficiency can be grouped into 4 bands:
3. red -> 30-59% efficiency
4. black -> <30% efficient

These percentage ranges are calculated as `(generated_power/ theoretical_max_power)*100`
where generated `power = voltage * current`
These percentage ranges are calculated as `(generated_power/theoretical_max_power)*100`
where `generated_power = voltage * current`

Implement the function `reactor_efficency()`, with three parameters: `voltage`,
`current`, and `theoretical_max_power`.
Expand All @@ -56,7 +56,7 @@ Criticality can then be increased, decreased, or stopped by inserting (or removi
Implement the function called `fail_safe()`, which takes 3 parameters: `temperature`,
`neutrons_produced_per_second`, and `threshold`, and outputs a status code for the reactor.

- If `temperature * neutrons_per_second` < 40% of threshold, output a status code of 'LOW'
- If `temperature * neutrons_per_second` < 40% of `threshold`, output a status code of 'LOW'
indicating that control rods must be removed to produce power.

- If `temperature * neutrons_per_second` are within plus or minus 10% of the `threshold`
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/meltdown-mitigation/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ When paired with `if`, an optional `else` code block will execute when the origi
x = 5
y = 10

# The comparison '>' here returns the bool False,
# The comparison '>' here returns the bool 'False',
# so the 'else' block is executed instead of the 'if' block.
if x > y:
print("x is greater than y")
Expand All @@ -42,7 +42,7 @@ x = 5
y = 10
z = 20

# The elif statement allows for the checking of more conditions.
# The 'elif' statement allows for the checking of more conditions.
if x > y:
print("x is greater than y and z")
elif y > z:
Expand All @@ -53,7 +53,7 @@ else:
>>> z is great than x and y
```

[Boolen operations][boolean operations] and [comparisons][comparisons] can be combined with conditionals for more complex testing:
[Boolean operations][boolean operations] and [comparisons][comparisons] can be combined with conditionals for more complex testing:

```python

Expand Down
12 changes: 6 additions & 6 deletions exercises/concept/meltdown-mitigation/.meta/exemplar.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
def is_criticality_balanced(temprature, neutrons_emitted):
def is_criticality_balanced(temperature, neutrons_emitted):
'''

:param temprature: int
:param temperature: int
:param neutrons_emitted: int
:return: boolen True if conditions met, False if not
:return: boolean True if conditions met, False if not

A reactor is said to be critical if it satisfies the following conditions:
- The temperature less than 800.
- The number of neutrons emitted per second greater than 500.
- The product of temperature and neutrons emitted per second less than 500000.
'''
output = temprature * neutrons_emitted
output = temperature * neutrons_emitted

if (temprature < 800 and neutrons_emitted > 500) and output < 500000:
if (temperature < 800 and neutrons_emitted > 500) and output < 500000:
return True
else:
return False
Expand Down Expand Up @@ -57,7 +57,7 @@ def fail_safe(temperature, neutrons_produced_per_second, threshold):
:param threshold:
:return: str one of: 'LOW', 'NORMAL', 'DANGER'

- `temperature * neutrons per second` < 40% of threshold == 'LOW'
- `temperature * neutrons per second` < 40% of `threshold` == 'LOW'
- `temperature * neutrons per second` +/- 10% of `threshold` == 'NORMAL'
- `temperature * neutron per second` is not in the above-stated ranges == 'DANGER'
'''
Expand Down
12 changes: 6 additions & 6 deletions exercises/concept/meltdown-mitigation/conditionals.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
def is_criticality_balanced(temprature, neutrons_emitted):
def is_criticality_balanced(temperature, neutrons_emitted):
'''

:param temprature: int
:param temperature: int
:param neutrons_emitted: int
:return: boolen True if conditions met, False if not
:return: boolean True if conditions met, False if not

A reactor is said to be critical if it satisfies the following conditions:
- The temperature less than 800.
- The number of neutrons emitted per second greater than 500.
- The product of temperature and neutrons emitted per second less than 500000.
- The temperature is less than 800.
- The number of neutrons emitted per second is greater than 500.
- The product of temperature and neutrons emitted per second is less than 500000.
'''
pass

Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/meltdown-mitigation/conditionals_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ class TestConditionals(unittest.TestCase):
def test_is_criticality_balanced_set1(self):

self.assertTrue(is_criticality_balanced(
temprature=750, neutrons_emitted=650), msg="Expected True but returned False")
temperature=750, neutrons_emitted=650), msg="Expected True but returned False")

@pytest.mark.task(taskno=1)
def test_is_criticality_balanced_set2(self):

self.assertTrue(is_criticality_balanced(
temprature=799, neutrons_emitted=501), msg="Expected True but returned False")
temperature=799, neutrons_emitted=501), msg="Expected True but returned False")

@pytest.mark.task(taskno=1)
def test_is_criticality_balanced_set3(self):

self.assertTrue(
is_criticality_balanced(temprature=500, neutrons_emitted=600), msg="Expected True but returned False"
is_criticality_balanced(temperature=500, neutrons_emitted=600), msg="Expected True but returned False"
)

@pytest.mark.task(taskno=1)
def test_is_criticality_balanced_set4(self):

self.assertFalse(
is_criticality_balanced(temprature=800, neutrons_emitted=500), msg="Expected False but returned True"
is_criticality_balanced(temperature=800, neutrons_emitted=500), msg="Expected False but returned True"
)

# End of first functions testing
Expand Down