O GoConqr está de visual novo! Conte para nós o que você achou.

Módulo 2 de 4 · Texto

Arithmetic operators: exponentiation

David Khieu

Arithmetic operators: exponentiation 

A ** (double asterisk) sign is an exponentiation (power) operator. Its left argument is the base, its right, the exponent.

Classical mathematics prefers notation with superscripts, just like this: 2^3. Pure text editors don't accept that, so Python uses ** instead, e.g., 2 ** 3. 

Take a look at our examples in the editor window. 

Note: we've surrounded the double asterisks with spaces in our examples. It's not compulsory, but it improves the readability of the code. 

The examples show a very important feature of virtually all Python numerical operators. 

Run the code and look carefully at the results it produces. Can you see any regularity here? 

Remember:  It's possible to formulate the following rules based on this result: 

  • when both ** aruguments are integers, the result is an integer, too
  • when at least one ** argument is a float, the result is a float, too

This is an important distinction to remember. 

 

Instruções

Para avançar no curso, envie uma tentativa deste quiz. Você pode enviá-la depois da última pergunta.

Ir para o módulo escolhido

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?