Get the App
SLTechnology News&Howtos  ›  Development  › 

How python returns a Boolean value

Shulou Source: shulou.com Published: 2022-06-01 04:43:59 10月03日 Update

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!

Tags: Boolean condition content article method learning help output same parameter easy to understand more organization knowledge procedure ribbon industry sentence information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Xiaomi Shulou Tech Info Huawei