These snippets show how to assign a Material to a prim. The technical term in USD is to bind the material. The example here applies to any UsdShade.Material.
For more information on creating materials, see Create an MDL Material and Create a UsdPreviewSurface Material.