How python returns a Boolean value
This article mainly shows you "python how to return Boolean value", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how python returns Boolean value" this article.
Returns a Boolean value
Sometimes we have to return a Boolean value by checking the conditions of some parameters. Instead of writing an if statement, we can return the condition directly. The following program will produce the same output.
Method I-use other conditions
Def function (n): if (n > 10): return True else: return False n = int (input ()) if (function (n): print ("Eligible") else: print ("Not Eligible")
Method II- has no other conditions
Def function (n): return n > 10 n = int (input ()) print ("Eligible") if function (n) else print ("Not Eligible")
Output quantity
Eligible above is all the content of the article "how to return a Boolean value by python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!