Python Morsels: Conditional operators in Python :

Python Morsels: Conditional operators in Python
by:
blow post content copied from  Planet Python
click here to view original post


Python's conditional operators return Boolean values (True and False).

What are Booleans?

We have three lists here, two of which represent the same data.

>>> a = [1, 2, 3]
>>> b = [1, 2, 3]
>>> c = [4, 5, 6]

If we wanted to ask whether two objects represent the same thing in Python, we can use the equals-equals (==) operator (a.k.a. the "equality operator"):

>>> a == b
True

The == operator will respond with either True or False.

>>> a == c
False

True and False are both of the type bool, which stands for Boolean:

>>> type(True)
<class 'bool'>

Booleans are how we represent "yes and no" or "affirmative and negative" in Python.

Booleans are often returned when using comparison operations, like equality (==).

Expressions that return either True or False (like a == b) are sometimes called Boolean expressions.

Where are Boolean expressions used?

Boolean expressions are often used …

Read the full article: https://www.pythonmorsels.com/conditional-operators/


February 06, 2023 at 09:30PM
Click here for more details...

=============================
The original post is available in Planet Python by
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce