Module 1
operations, basic operators,data types, variables,
basic input-output
Operators
Module 1 Operators
Basic operators
+ - * / // % **
Data and operators when connected
together form expressions.
Module 1 Operators
Exponentiation, multiplication
print(2 ** 3)
print(2 ** 3.)
print(2. ** 3)
print(2. ** 3.)
8
8.0
8.0
8.0
When both ** arguments are integers, the result is
an integer, too;
When at least one ** argument is a float, the result
is a float, too.
print(2 * 3)
print(2 * 3.)
print(2. * 3)
print(2. * 3.)
6
6.0
6.0
6.0
Module 1 Operators
Division, integer division
print(6 / 3)
print(6 / 3.)
print(6. / 3)
print(6. / 3.)
2.0
2.0
2.0
2.0
print(6 // 3)
print(6 // 3.)
print(6. // 3)
print(6. // 3.)
2
2.0
2.0
2.0
Module 1 Operators
Basic operators
print(14 % 4)
print(12 % 4.5)
print(-4 + 4)
print(-4. + 8)
print(-4 - 4)
print(4. - 8)
print(-1.1)
print(+2)
2
3.0
0
4.0
-8
-4.0
-1.1
2
Module 1 Operators
List of priorities
Priority Operator
1 +, - unary
2 **
3 *, /, //, %
4 +, - binary
Left-sided binding
• print(9 % 6 % 2)
Right-sided
binding
• print(2 ** 2 ** 3)
Module 1 Operators
Key takeaways
• An expression is a combination of values;
• Operators are special symbols or keywords;
• Arithmetic operators in Python;
• A unary operator, a binary operator;
• The hierarchy of priorities;
• The exponentiation operator uses right-sided binding.

Python PCEP Operators

  • 1.
    Module 1 operations, basicoperators,data types, variables, basic input-output Operators
  • 2.
    Module 1 Operators Basicoperators + - * / // % ** Data and operators when connected together form expressions.
  • 3.
    Module 1 Operators Exponentiation,multiplication print(2 ** 3) print(2 ** 3.) print(2. ** 3) print(2. ** 3.) 8 8.0 8.0 8.0 When both ** arguments are integers, the result is an integer, too; When at least one ** argument is a float, the result is a float, too. print(2 * 3) print(2 * 3.) print(2. * 3) print(2. * 3.) 6 6.0 6.0 6.0
  • 4.
    Module 1 Operators Division,integer division print(6 / 3) print(6 / 3.) print(6. / 3) print(6. / 3.) 2.0 2.0 2.0 2.0 print(6 // 3) print(6 // 3.) print(6. // 3) print(6. // 3.) 2 2.0 2.0 2.0
  • 5.
    Module 1 Operators Basicoperators print(14 % 4) print(12 % 4.5) print(-4 + 4) print(-4. + 8) print(-4 - 4) print(4. - 8) print(-1.1) print(+2) 2 3.0 0 4.0 -8 -4.0 -1.1 2
  • 6.
    Module 1 Operators Listof priorities Priority Operator 1 +, - unary 2 ** 3 *, /, //, % 4 +, - binary Left-sided binding • print(9 % 6 % 2) Right-sided binding • print(2 ** 2 ** 3)
  • 7.
    Module 1 Operators Keytakeaways • An expression is a combination of values; • Operators are special symbols or keywords; • Arithmetic operators in Python; • A unary operator, a binary operator; • The hierarchy of priorities; • The exponentiation operator uses right-sided binding.