3. Operators

3.1. Operator precedence

Table 18. Operator precedence

Operator

Description

lambda

Lambda expression

if, elif, else

Conditional expression

and

Boolean AND

or

Boolean OR

not x

Boolean NOT

in, not in, is, is not,

<, <=, >, >=, !=, ==

Comparisons, including membership tests and identity tests

|

Bitwise OR

^

Bitwise XOR

&

Bitwise AND

<<, >>

Shifts

**

Exponentiation

*, @, /, //, %

Multiplication, matrix multiplication, division, floor division, remainder

+, -

Addition and subtraction

+x, -x, ~x

Positive, negative, bitwise NOT

await

Await expression

x[index], x[index:index],

x(arguments...), x.attribute

Subscription, slicing, call, attribute reference

(expressions...), [expressions...],

{key: value...}, {expressions...}

Binding or tuple display, list display, dictionary display, set display

3.2. Assignments

3.2.1. To float or to int?

English
  1. Read a number from user

  2. User will pass only valid int or float

  3. Integer is when number modulo divided by one has no reminder

  4. Print whether number is int or float

Polish
  1. Wczytaj od użytkownika liczbę

  2. Poda tylko int albo float

  3. Liczba jest całkowitą gdy podzielona modulo przez jeden nie ma reszty

  4. Wyświetl informację czy jest to liczba całkowita, czy rzeczywista

The whys and wherefores
  • Reading input

  • Type casting

  • Conditional statements

  • Defining variables

  • Magic Number