Update 7/30/20: use this newer version # There are 2 functions in this snippet# 1.…