the value for the 'rotationkey is random integer between to one less than however many possible rotations there are for that shape the number of rotations for shape can be found from the expression len(shapes[shape]notice that we don' store the list of string values (like the ones store in the constants like s_shape_templatein each piece data structure to represent the boxes of each piece insteadwe just store an index for the shape and rotation which refer to the pieces constant the 'xkey' value is always set to the middle of the board (also accounting for the width of the pieces themselveswhich is found from our templatewidth constantthe 'ykey' value is always set to - to place it slightly above the board (the top row of the board is row since the colors constant is tuple of the different colorsselecting random number from to the length of colors (subtracting onewill give us random index value for the piece' color once all of the values in the newpiece dictionary are setthe getnewpiece(function returns newpiece adding pieces to the board data structure def addtoboard(boardpiece) fill in the board based on piece' locationshapeand rotation for in range(templatewidth) for in range(templateheight) if shapes[piece['shape']][piece['rotation']][ ][ !blank board[ piece[' ']][ piece[' ']piece['color'the board data structure is data representation for the rectangular space where pieces that have previously landed are tracked the currently falling piece is not marked on the board data structure what the addtoboard(function does is takes piece data structure and adds its boxes to the board data structure this happens after piece has landed the nested for loops on lines and go through every space in the piece data structureand if it finds box in the space (line )it adds it to the board (line creating new board data structure def getblankboard() create and return new blank board data structure board [ for in range(boardwidth) board append([blankboardheight