Digit Insurance interview question

Basic python codes, design question