Byte Checksum Check

In binary protocols, a checksum helps detect whether data was damaged during transfer. Given a list packet, the last byte is already included in the total as the checksum byte. Return True if the sum of all bytes modulo 256 is equal to 0. Otherwise, return False.

Примеры

Ввод
[10, 20, 226]
Вывод
True
Ввод
[0]
Вывод
True
Ввод
[1, 2, 3]
Вывод
False

Нужно реализовать

def checksum_ok(packet):

Теги

arraylistsmath
PostgreSQLv16

Itt jelenik meg a kód futtatásának eredménye

Visible tests
1
Input
[10,20,226]
ExpectedTrue
2
Input
[0]
ExpectedTrue
3
Input
[1,2,3]
ExpectedFalse
4
Input
[255,1]
ExpectedTrue
5
Input
[100,100,56]
ExpectedTrue
6
Input
[100,100,55]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid