Operators
The subject of operators is what we'll learn next. To handle variables or values and perform actions on them, we need operators. There are many various kinds of operators, and in this chapter, we'll discuss their variations and uses. Arithmetic Operators Arithmetic operators are the most basic operators. They are presumably familiar to you from maths.
Click ▸ to run the python interpreter below
Assignments Operators
We are also familiar with assignment operators as another category of operators. We use them to provide variables values, as their name already implies. Basically, we assign a value directly using these operators. The two sentences that follow each have the same impact. It's simply easier to write that way.
Click ▸ to run the python interpreter below
Comparison Operators We always obtain a Boolean when we employ comparison operators to compare two items. As a result, our conclusion can either be True or False. When working with conditions and loops, we employ comparisons. We shall discuss these two subjects in more detail in following chapters. A comparison returns True if it is accurate, and False if it is incorrect. Let's examine a few instances.
Click ▸ to run the python interpreter below
Logical Operators
To combine or connect Booleans or comparisons, logical operators are needed. I think this is best explained by examples, so let’s look at some.
Click ▸ to run the python interpreter below
VARIOUS OPERATORS
Other operators include bitwise operators and membership operators. However, some of them are unnecessary, and understanding others requires a little more programming expertise.
0 Comments
Leave a Reply. |
AuthorAnything you need to know about computer science Archives
May 2023
Categories
All
|