Python pow() funktion

Exempel

Returnera 5 till 3:e potens (lika med 5 * 5 * 5):

x = pow(5, 3)

Kör Exempel

Definition och Användning

pow() funktionens värde av x till y:e potens (xy).

Om tredje parametern tillhandahålls, returneras x till y:e potens och tar resten z.

Syntax

pow(x, y, z)

Parametervärde

Parameter Beskrivning
x Tal, bas.
y Tal, exponent.
z Valfritt. Tal, modulus.

Mer Exempel

Exempel

Returnera 5 till 3:e potens modulo 4 (lika med (5 * 5 * 5) % 4):

x = pow(5, 3, 4)

Kör Exempel