India Languages, asked by ravinderpalsingh319, 2 months ago

REVIEW PYTHON operators

Answers

Answered by issuatstudy090
0

What are Logical Operators in Python?

Logical Operators in Python are used to perform logical operations on the values of variables. The value is either true or false. We can figure out the conditions by the result of the truth values. There are mainly three types of logical operators in python: logical AND, logical OR, and logical NOT. Operators are represented by keywords or special characters.

Arithmetic Operators perform various arithmetic calculations like addition, subtraction, multiplication, division, %modulus, exponent, etc. There are various methods for arithmetic calculation in Python like you can use the eval function, declare variable & calculate, or call functions.

Example: For arithmetic operators, we will take a simple example of addition where we will add two-digit 4+5=9

x= 4

y= 5

print(x + y)

Similarly, you can use other arithmetic operators like multiplication(*), division (/), subtraction (-), etc.

Comparison Operators

Comparison Operators In Python compares the values on either side of the operand and determines the relation between them. It is also referred to as relational operators. Various comparison operators in python are ( ==, != , <>, >,<=, etc.)

Example: For comparison operators, we will compare the value of x to the value of y and print the result iasn true or false. Here in the example, our value of x = 4 is smaller than y = 5, so when we print the value as x>y, it actually compares the value of x to y and since it is not correct, it returns false.

x = 4

y = 5

print(('x > y  is',x>y))

Likewise, you can try other comparison operators (x < y, x==y, x!=y, etc.)

Python Assignment Operators

Assignment Operators in Python are used for assigning the value of the right operand to the left operand. Various assignment operators used in Python are (+=, - = , *=, /= , etc.).

Example: Python assignment operators simply assign the value, for example

num1 = 4

num2 = 5

print(("Line 1 - Value of num1 : ", num1))

print(("Line 2 - Value of num2 : ", num2))

HOPE THIS HELPS!!!!!!!!!!

Similar questions