I need some help understanding why my code doesn’t work.
First off the tasks says:
- 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:
Code I got from a right solution
if temperature < 800 and neutrons_emitted > 500:
return (temperature * neutrons_emitted) < 5e5
I don’t understand why mine doesn’t work. For my if statement I’m looking at three conditions. If temp < 800, if emitted > 500, and if the sum of them is less than 500,000. What logic am I doing wrong? Why does the right code work and mine fails?
Hi demaiokenneth! I don’t know if you type the code here wrong or not, but for me, it works correctly! No error. Can you show the error message that shows to you?
As @tiagocazali says, you should start by reading the error. And telling us what it is?
But I would ask, is
true a thing in Python?
This is what I see if I try and use the word
true on my local machine in Python 3…
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'true' is not defined. Did you mean: 'True'?
Ha!!! You must use the word “True” , not “true”. (with T ) capital letter!
I tested in my computer, but probably fixed automatically the T and F! And I focused in the IF sentence, not in the return! kkk
OMG. Lol. Thank you so much. <3