Basically as any other language setAttr can set a value for a specified attribute of a node or any context. And it support very wide range of options. For detailed instructions please visit the official documentation from maya itself here.
Here is a very minimal example of setAttr
nodeName = "pSphere1" cmds.setAttr("%s.tx" % nodeName, 10)
getAttr Same as setAttr here it will give back the value from a specific attribute from a node. And it can return multiple types of dataTypes also. Autodesk has well documented the command here
Here is a very minimal example of getAttr
nodeName = "pSphere1" txValue = cmds.getAttr("%s.tx" % nodeName)