PYTHON DICTIONARY
CommentsData typesVariablesIf ElseIf Elif ElseFunctionsFor loopWhile loopData structuresString slicingUser defined functionLocal/Global variableValidation and TryMethodsFile I/OPseudocodeModulesClasses |
What is a class?In the example below, our object will be a football team and the variables and functions will enable a team to score a goal or a penalty. (Before learning what a class is, you will first need an appreciation of user defined functions and variables.)
One object (e.g. football team) will be an instance of our class and have access to all the attributes within that class. A second object (e.g. a different football team) will be a separate instance of a our class and have access to all the same attributes within that class as our first football team did. Although both teams use the attributes in the class (e.g. score goals or score penalties) we like Python because holds each of the football team’s data entirely separately. - Here is a full example of a "class" called "FootballTeam" - See below for a breakdown
|