The code shown generates the output shown. Does it not run for you? I didn't type it out (can't copy and paste from an image) so it seems fine at first glance.
Is there something else you're looking for beyond this?
Go through each line of the code and add your comments to what you think it's doing. Post that back and we'll show you where your understanding may be incorrect.