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

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

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes