#Python: Meltdown Mitigation

19 messages · Page 1 of 1 (latest)

ionic goblet
#

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.

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

code:

    
    if temperature <= 800 and neutrons_emitted > 500 and temperature * neutrons_emitted <= 500000:
        return True
    else:
        return False 

Why do all the test cases fail?

nocturne oasis
#

The exact test details are worth looking at. What exactly is the test running? What does it expect to get? What does it actually get? How do those values differ? Why?

#

Try answering as many of those questions as possible

desert sigil
#

also one little thing to keep in mind in the future when using conditionals and Booleans:

if x < y:
  return True
else
  return False

is the same as

return x < y
ionic goblet
# nocturne oasis Try answering as many of those questions as possible

I did look into the test, it doesn't make sense to me even after an hour of trying to figure out whats wrong with the code. one of the tests use decimals (500.01), i tried to convert it to int and it still didn't work

for example:

how can this be true by looking at my code? The code says: if temperature is less than or equal to 800 and neutrons emitted is greater than 500, AND the product of those is 500,000, return true
otherwise return false

#

but somehow EVERY test case fails, not just one or two

#

I'm not sure if this is a bug or something else

#

or is something staring at me in the eyes and i don't see it?

ionic goblet
desert sigil
#

running the code myself, the tests don't completely fail; there's just at least one variant of each test that fails, like for Test #2 everything is okay until it gets to the variant with T=800 and neutrons=500.01

#

but we can look at that particular case and maybe identify what's going on by comparing it to the problem statement

#

the temperature is 800, so does that meet the temperature-related condition in the requirement?

ionic goblet
#

one more thing, one of the errors I get is this:

#

AssertionError: None != False : Expected False but returned None with T=1000 and neutrons=800

#

i thought by default python considers none as false?

desert sigil
#

is 800 less than 800?

ionic goblet
nocturne oasis
#

Please do!