Comprehensive Python

Table Of Contents:

Python Variables and Datatypes

In the Previous lesson, we looked in some of the critical parts of python especially their meanings so that we may prepare ourselves for python programming.
It happened that in the tutorial, we too met variables and some datatypes, i.e Lists, Strings etc.
Now that we know what variables and/or datatypes are, it's time to dismantle all of them piece-by-piece.

Python Variables

The previous lesson made some clarification of what a variable is... and in this section, we will have a precise understanding of variables and so forth.
As already said, a python variable, or variable in short, is a name (ussually following conversion), used to store or reference data value in memory.
The variable stores the reference to a value in stack.
A stack is a point in memory for storing data... calling/using the variable name will result in its real value being used.
and deleting a variable results in the removal of the reference of the value in a stack.
defining a variable in python, unlike in C++ or other strongly typed languages, do not require explicit declaration of data type, that is, the type of data stored is automatically determined by python.
Python variables are given values during declaration, except in scope where keyword global is used.
appropriate definition of variables in python would be:
>>>variable = value
or, you may use the global keyword and define later. example:
>>> global variable
>>> variable = value
all the above usages are true and correct in python.
some of the additional keywords may include local, nonelocal etc.

Variable Identifiers

An Identifier is a word given to a variable as a variable name. in the above section, a word variable was used as a name,
and is therefore a reasonable example of a python variable Identifier.
The Python variable naming conversions follow the ettiquete below:
  1. Python keywords cannot be used as identifirs, eg class=20 is wrong
  2. Variable names must start with a letter or underscore : eg people,Days, _papers
  3. Variable names do not start with a Number: 8names, is an example of wrong identifier and will pop an error.
  4. Variable names do not contain spaces : my books, is a wrong identifier
  5. Variable names do not contain a hyphen, this is kept as an operator: number-of-people, is wrong identifier
  6. To name a variable with more than one word, you may use underscore, eg my_books or use camel case, eg myBooks

Keeping this in mind, you'll write the best identifiers eversince on this earth.

Python Data Types

Now that we know how to declare and use variables in python, it's time to store some data in them.
The data that can be stored in python variables come in different types, eg Numbers, Strings(text),Lists, etc and most of them we discovered in previous lesson.
To begin with, let's start by looking at the Numbers datatype.