<jupyter_start><jupyter_text>python-3-2-what-is-logical-and-comparison-operator-412Use the "Run" button to execute the code.<jupyter_code>!pip install jovian --upgrade --quiet
import jovian
# Execute this to save new versions of the notebook
jovian.commit(project="python-3-2-what-is-logical-and-comparison-operator-412")<jupyter_output><empty_output><jupyter_text>Basic Introduction to Python   Python is a high level programming level which has gained popularity due to its simplicity and ease to use.It offers a wide range of libraries to perform various functions thereby reducing the lines of code. Unlike the other age old programming languages Python has very few restrictions in terms of syntax and semantics.  Operators Operators are used to perform operations on variables and values.They help us to perform calculations and express pharses in a mathematically way.Python divides the operators in the following groups:1) Arithmetic operators2) Assignment operators3) Comparison operators4) Logical operators5) Identity operators6) Membership operators7) Bitwise operators  Arithmetic Operators Arithmetic operators are used with numeric values to perform common mathematical operations.Operands for the arithmetic operators can be integers or real numbers.  Addition  (+)<jupyter_code># Variable x is assigned value 10 and variable y is assigned value 15.
x=10      
y=15
 # Variable z stores the sum of variable x and variable y.
z= x+y  
# Printing the value of variable z.
print(z)<jupyter_output>25<jupyter_text>Subtraction  (-)<jupyter_code># Variable a is assigned value 22 and variable b is assigned value 11.
a=22     
b=11      
# Variable c stores the difference between variable a and variable b.
c= a-b 
# Printing the value of variable c.
print(c)<jupyter_output>11<jupyter_text>Multiplication  (*)<jupyter_code># Variable x is assigned value 10 and variable y is assigned value 15.
x=10      
y=15      
# Variable z stores the product of variable x and variable y.
z= x*y    
# Printing the value of variable z.
print(z)<jupyter_output>150<jupyter_text>Division (/)<jupyter_code># Variable x is assigned value 18 and variable y is assigned value 9.
x=18      
y=9      
# Variable z stores the quotient after dividing variable x by variable y. The output is in decimal form.
z= x/y   
# Printing the value of variable z. 
#(Notice that even thought x is perfectly divisible by y, yet the output returned is a float and not an integer)
print(z)<jupyter_output>2.0<jupyter_text>Modulus (%)<jupyter_code># Variable x is assigned value 18 and variable y is assigned value 10.
x=18      
y=10     
# Variable z stores the remainder after dividing variable x by variable y.
z= x%y   
# Printing the value of variable z.
print(z)<jupyter_output>8<jupyter_text>Exponentiation (**)<jupyter_code># Variable x is assigned value 2 and variable y is assigned value 3.
x=2     
y=3     
# Variable z stores x to the power y.
z= x**y  
# Printing the value of variable z.
print(z)<jupyter_output>8<jupyter_text>Floor division(//)<jupyter_code># Variable x is assigned value 6 ,variable y is assigned value 3 and variable w is assigned value 4.
x=6     
y=3 
w=4
# Variable z stores the result of integer division of x by y.
z= x//y  
# Printing the value of variable z. 
# (Notice that x is perfectly divisibly by y and the output of the integer divison stored in variable z is an integer value)
print(z)  
# Variable z1 stores the result of integer division of x by w.
z1=x//w
# Printing the value of variable z1. 
# (Notice that x is not perfectly divisibly by w and the output of the integer divison stored in variable z1 is still an integer value)
print(z1)<jupyter_output>1<jupyter_text>Comparision Operators Comparision Operators are used for comparing the values. It either returns True or False according to the condition. These operators are also known as Relational Operators.  Greater Than (>) Greater than: True if the left operand is greater than the right<jupyter_code># Variable x is assigned value 10,variable y is assigned value 7 and variable z is assigned value 15.
x=10      
y=7
z=15
# Since x > y is correct, True will be returned.
x>y
# Since x > z is incorrect, False will be returned.
x>z<jupyter_output><empty_output><jupyter_text>Less Than (<) Less than: True if the left operand is less than the right<jupyter_code># Variable x is assigned value 10,variable y is assigned value 7 and variable z is assigned value 15.
x=10      
y=7
z=15
# Since x < y is incorrect, False will be returned.
x<y
# Since x < z is correct, True will be returned.
x<z<jupyter_output><empty_output><jupyter_text>Equal To (==) Equal to: True if both operands are equal<jupyter_code># Variable x is assigned value 4,variable y is assigned value 4 and variable z is assigned value 5.
x=4
y=4
z=5
# Since x==y==4 is correct, True will be returned. 
x==y
# Since x==z==4 is incorrect, False will be returned. 
x==z<jupyter_output><empty_output><jupyter_text>Not Equal To (!=) Not equal to: True if operands are not equal<jupyter_code># Variable x is assigned value 4,variable y is assigned value 4 and variable z is assigned value 5.
x=4
y=4
z=5
# Since x!=y is incorrect, False will be returned. 
x!=y
# Since x!=z is correct, True will be returned. 
x!=y<jupyter_output><empty_output><jupyter_text>Greater Than or Equal To (>=) Greater than or equal to: True if left operand is greater than or equal to the right<jupyter_code># Variable x is assigned value 5,variable y is assigned value 3 and variable z is assigned value 4.
x=5
y=3
z=4
# Since x>=y is correct, True will be returned 
x>=y
# Since y>=z is incorrect, False will be returned
y>=z<jupyter_output><empty_output><jupyter_text>Less Than or Equal To (<=) Less than or equal to: True if left operand is less than or equal to the right<jupyter_code># Variable x is assigned value 5,variable y is assigned value 3 and variable z is assigned value 4.
x=5
y=3
z=4
# Since y<=z is correct, True will be returned 
y<=z
# Since x<=y is incorrect, False will be returned
x<=y<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06969846762234305, 'fraction_numerical': 0.02109078925687922, 'mean_word_length': 4.523202911737943, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '152696', 'license': 'MIT', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1818, 'n_words': 857, 'path': 'Python/Operators/python-3-2-what-is-logical-and-comparison-operator-412.ipynb', 'repo_name': 'SouravKr2001/winter-of-contributing', 'size': '6069'}