Python operators


  Translation results:

The Python language supports the following types of operators:

Arithmetic operators

Comparison (relational) operators

Assignment operators

< p>Logical operators

Bit operators

Member operators

Identity operators

Operator precedence

Python operatorssyntax

The Python language supports the following types of operators:

Arithmetic operators

Comparison (relational) operators

Assignment operators

< p>Logical operators

Bit operators

Member operators

Identity operators

Operator precedence

Python operatorsexample

#!/usr/bin/python# -*- coding: UTF-8 -*-
a = 21
b = 10
c = 0
c = a + b
print "1 - The value of c is:", c
c = a - b
print "2 - The value of c is: ", c
c = a * b
print "3 - The value of c is:", c
c = a / b
print "4 - The value of c is:", c
c = a % b
print "5 - The value of c is:", c
# Modify variables a, b, c
a = 2
b = 3
c = a**b
print "6 - The value of c is: ", c
a = 10
b = 5
c = a//b
print "7 - The value of c is:", c

Popular Recommendations

Home

Videos

Q&A