The python code used in this tutorial will be split into two parts where the first part is the code used when assigning a new PIN code to your IOTA debit card. The second part is a modified version of the iota_debit_card_pay.py script from the previous tutorial. Only difference is that the new version will ask you for a PIN code before scanning your IOTA debit card.
So lets start with the first Python script that will allow you to assign your own four digit PIN code to your IOTA debit card. Notice that the new PIN code will be written to the first four bytes of both block 11 and 15. The reason we need to write the PIN code to two different blocks is that each block functions as an the authentication block for the two individual sectors where the IOTA seed is stored. Check out the 6th tutorial in this series for more information on reading and writing data from the Mifare RFID tag.