PYTHON DICTIONARY
CommentsData typesVariablesIf ElseIf Elif ElseFunctionsFor loopWhile loopData structuresString slicingUser defined functionLocal/Global variableValidation and TryMethodsFile I/OPseudocodeModules |
What is a Data type?I know what they are called, but what are they exactly?You now know the names of four data types, but what exactly are they?
INTEGAR: This is a number which does NOT have a decimal. It can be positive, negative or zero. e.g. 10, -273, 2001. FLOAT: This is a number that contains a decimal point e.g. 3.141 BOOLEAN: A type of data that has one of two values e.g. True/False STRING: A letter, number or character or a combination of e.g. "50% off" Why have different data types?When you start writing programs, you will want to be specific about what it does and how it handles your data. For example, many action games will contain "health" data or "number of lives" data. Which data type would you use to count how many lives you have left?
Python ChallengeIn Python Shell, type the following then press enter
What does it do? Is it useful? Retry it with help(float), help(bool) and help(str)
Python ChallengeName that data type. See if you can guess the type of data being displayed in the following variables
Superhero= "spiderman"
"Spiderman" is a string FootballGamesUnbeaten = 38
38 is an integar alive = true
True is a boolean virginbroadband = 17.50
17.50 is a float |