Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Operator in python programming language

Posted on April 19, 2017September 15, 2019

Table of Contents

  • Operator in python programming language
      • Arithmetic operators 
      • Comparison operators
      • Logical operators
      • Bitwise operators
      • Assignment operators
    • Related

Operator in python programming language

Python programming language provides many types of operator for arithmetic calculations and operations.


Arithmetic operators 

Arithmetic operators are used to perform mathematical calculations or operations.

Operator in python programming language
Arithmetic
 
Example for arithmetic operators
 
program 1
 
Operator in python programming language
Example

Comparison operators

Comparison operators are used to compare values. It either returns true or false values only according to the given condition.
Operator in python programming language
Comparision
Example 1
Operator in python programming language
Comparision example

Logical operators

The logical operator are used in conditional statements that are true or false. The logical operator in Python are AND or OR or NOT
There are three logical operators available in python
Operator in python programming language
Logical
Example 1
AND operator
Operator in python programming language
Logical examplw
Output
(‘a and a:’, True)
(‘a and b:’, False)
(‘b and b:’, False)
Example 2
OR operator
Output
a or a: True
a or b: True
b or b: False
Example 3
NOT operator
Output
not a: False
not b: True

Bitwise operators

Operator in python programming language
Bitwise
Program 1
Output
value of x&y 18
value of x|y 63
value of x^y 45
value of ~y -19
value of x<<2 -19
value of x>>2 -19

 

Assignment operators

Assignment operators are used in python to assign values to the variable

Operator in python programming language
Assignment
Program 1
Output
value of a=x+y : 42
value of a+=y : 52
value of a*=y : 520
value of a/=y : 52
value of a%=y : 2
value of a**=y : 1024
value of a**=y : 102

 

Similar post

The operator in Java language
The operator in C++ language
The operator in C language

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes