Python math.fmod() Metode
Contoh
Kembalikan sisa x/y:
# Import math Library
import math
# Return the remainder of x/y
print(math.fmod(20,
4))
print(math.fmod(20, 3))
print(math.fmod(15, 6))
print(math.fmod(-10, 3))
print(math.fmod(0, 0))
Definisi dan Penggunaan
Metode math.fmod()
ini mengembalikan sisa (modulo) dari x/y.
Sintaksis
math.fmod(x, y)
Nilai Parameter
Parameter | Description |
---|---|
x | Required. A positive or negative number to divide |
y | Required. A positive or negative number to divide x with |
Catatan: Jika x dan y = 0, ia mengembalikan ValueError.
Catatan: Jika y = 0, ia mengembalikan ValueError.
Catatan: Jika x atau y bukan angka, ia mengembalikan TypeError.
Detail Teknis
Nilai Kembali: | Nilai float , mewakili sisa x/y |
---|---|
Versi Python: | 1.4 |