#Help with Meltdown Mitigation

36 messages · Page 1 of 1 (latest)

obtuse verge
#
    """Verify criticality is balanced.

    :param temperature: int or float - temperature value in kelvin.
    :param neutrons_emitted: int or float - number of neutrons emitted per second.
    :return: bool - is criticality balanced?

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

    if temperature < 800 or neutrons_emitted > 500 and temperature + neutrons_emitted < 500000:
        return True
    else:
        return False

why doesnt this work?

silent sluice
#

What were the errors? Please also post it in a codeblock

fallen meadow
#

@obtuse verge -- as @silent sluice has asked, what errors are you getting from the tests?

On the line if temperature < 800 or neutrons_emitted > 500 and temperature + neutrons_emitted < 500000: are you sure you want to be doing an or check? That looks a little bit odd to me.

obtuse verge
#

i also tried it as and

#

didnt work

#

ill get the errors 1 min

#

how do i post them

silent sluice
#

code block. copy paste into the block. please dont use screen shot. they are hard to read and hard to copy paste/ edit

obtuse verge
#

T, n == (800, 500), (625, 800), (500, 1000), etc.

"""

test_data = ((750, 650, True), (799, 501, True), (500, 600, True),
             (1000, 800, False), (800, 500, False), (800, 500.01, False),
             (799.99, 500, False), (500.01, 999.99, False), (625, 800, False),
             (625.99, 800, False), (625.01, 799.99, False), (799.99, 500.01, True),
             (624.99, 799.99, True), (500, 1000, False), (500.01, 1000, False),
             (499.99, 1000, True))

for variant, data in enumerate(test_data, start=1):
    temp, neutrons_emitted, expected = data
    with self.subTest(f'variation #{variant}', temp=temp, neutrons_emitted=neutrons_emitted, expected=expected):

        # pylint: disable=assignment-from-no-return
        actual_result = is_criticality_balanced(temp, 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)
TEST FAILURE
One or more variations of this test failed. Details can be found under each [variant#].```
#

T, n == (800, 500), (625, 800), (500, 1000), etc.

"""

test_data = ((750, 650, True), (799, 501, True), (500, 600, True),
             (1000, 800, False), (800, 500, False), (800, 500.01, False),
             (799.99, 500, False), (500.01, 999.99, False), (625, 800, False),
             (625.99, 800, False), (625.01, 799.99, False), (799.99, 500.01, True),
             (624.99, 799.99, True), (500, 1000, False), (500.01, 1000, False),
             (499.99, 1000, True))

for variant, data in enumerate(test_data, start=1):
    temp, neutrons_emitted, expected = data
    with self.subTest(f'variation #{variant}', temp=temp, neutrons_emitted=neutrons_emitted, expected=expected):

        # pylint: disable=assignment-from-no-return
        actual_result = is_criticality_balanced(temp, 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)
TEST FAILURE
AssertionError: True != False : Called is_criticality_balanced(1000, 800).  The function returned True, but the test expected False as the return value.```
silent sluice
#

One or more variations of this test failed. Details can be found under each [variant#].
click on the details and give the exact test that it fail

obtuse verge
#

10 tests

#
    """Verify criticality is balanced.

    :param temperature: int or float - temperature value in kelvin.
    :param neutrons_emitted: int or float - number of neutrons emitted per second.
    :return: bool - is criticality balanced?

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

    if temperature < 800 and neutrons_emitted > 500 and temperature + neutrons_emitted < 500000:
        return True
    else:
        return False
#

this also doesnt work

#

replacing the or with and

silent sluice
#

what does this mean "- The product of temperature and neutrons emitted per second is less than 500000." ?

obtuse verge
#

thats the comment from the question itself i didnt write that

silent sluice
#

yeah i know. it is a hint. what does it mean

obtuse verge
#

i think they mean that the temperature plus the neutrons emmited has to be less than 500000

silent sluice
#

are you sure it is plus?

#

google sum vs product

obtuse verge
#

ohhh alright

#

i mix them up alot

#

english isnt my first language

silent sluice
#

it happens. very understandable. that's why understand the problem statement is important

obtuse verge
#

alright it worked now

#

thank you so much

silent sluice
#

if you are using firefox or chrome you can download the extension "translate web pages"

#

and with just 1 click it will translate the current webpage to your language of your choosing

#

it might not be perfect but it will help

obtuse verge
#

oh okay thats useful

silent sluice
#

but the honest truth is that programming is very english bias, so knowing and learning english will also help

obtuse verge
#

yes true