#Conditionals.py

10 messages ยท Page 1 of 1 (latest)

limpid tundra
#

Please help cuz my brain isn't braining. It's been a while since I continued my python learning, but I thought I still understood the basics, but am not so sure not ๐Ÿ˜ฆ

I am currently stuck on the first function def is_criticality_balanced(temperature, neutrons_emitted)

my current code is:

def is_criticality_balanced(temperature, neutrons_emitted):
  if temperature < 800 and neutrons_emitted > 500 and     temperature * neutrons_emitted < 500000:
    True
  else:
    False

this is what it's supposed to do:
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 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.

I'm looking at it and to me, my code should do what it needs to do, but it doesn't. I have to admit I currently have a C brain, so maybe I'm implementing C syntax without realizing it, but shouldn't that give an error?

#

I'm sure the answer is probably obvious, but having a huge brainfart

obtuse coral
#

In Python, when a function returns a Boolean value, it is common to use the return keyword to do so, so why not consider doing so?

limpid tundra
#

omg ....

#

yeah

#

thanks

#

๐Ÿ˜‚ ๐Ÿฅฒ

obtuse coral
#

You're welcome! I'm glad I could help you. ๐Ÿ˜„ ๐ŸŽ‰

fringe geodeBOT
#

If everything is resolved, we ask that the person who posted the request react to the top/original post with a :white_check_mark: (:white_check_mark:). This indicates to others that this issue has been resolved and locks the thread.
If all the tests pass and you want to further improve your solution, we encourage you to use the "Request a Code Review" feature on the website!

obtuse coral
#

If you read the error message it should tell you the function was returning None which should help debug