This paper contains selected topics from four lectures given at the Abdus Salam International Centre for Theoretical Physics in May 2009. We introduce the study of the influence of knotting and linking on the spatial characteristics of linear and ring polymer chains with examples of scientific interest. We describe a few basic concepts of the geometry and topology of knots and measures of the spatial shape of open and closed polymer chains. We then present some fundamental mathematical results concerning them. Next we discuss random sampling methods of collections of open and closed chains that are employed to provide estimates of the spatial properties of the chains. Finally, we discuss implementations of the sampling algorithms, survey consequences of theoretical and experimental results, and discuss some interesting problems deserving further research.