Requirements:
1. Linux Distribution
2. python3
3. A Shell Interface
My Setup:
1. Debian GNU/Linux
2. python3
3. BASH
Despite the fact that python is a dynamically typed, variables still have a type to them. Variables are locations in memory which you may store values to be used within your program. The fundamental data types consist of :
- None – object that specifies a lack of value . The only value this can be is None
- bool – a data type which can only hold the values “True” or “False”. Evaluate to 1 and 0 respectively.
- int – a data type which represents whole numbers.
- float – a data type which represents floating-point numbers
- complex – a data type which represents complex numbers
- str – a data type which represents strings of characters. These can not be changed, and any operations on it will return a new string.
- list – a data type which represents an indexed list of objects. Operations on these will modify the current variable.
- tuple – a data type which represents an indexed list of objects. Operations on these will not modify the current variable, but return a new one.
- dict – a data type that represents a hash table for storing unordered key-value pairs. Operations on this will modify the current variable.
- set – a data type that represents an unordered list of unique objects. Operations on these will modify the current variable.
- file – a data type that represents a file object.
There are many data types within the modules that python has to offer, and you can create your own as well. In the previous chapter, I created an example of declaring a variable by writing a variable name and assigning it a value.
myNoneObj = None
myInt = 43
myStr = "This is A String"
myFloat = 3.1415
myComplex = 1 + 2j
print(type(myNoneObj)) # should result in NoneType
print(type(myInt)) # should result in int
print(type(myStr)) # should result in str
print(type(myFloat)) # should result in float
print(type(myComplex)) # should result in complex
clim@debian:~/Desktop/tests/pytests/typeTest$ python3 typetest.py
<class 'NoneType'>
<class 'int'>
<class 'str'>
<class 'float'>
<class 'complex'>
clim@debian:~/Desktop/tests/pytests/typeTest$
When declaring variables, there are some rules that we should keep in mind.
- The variable name cannot start with a number. It can only start with a character or an underscore.
- Variables in python are case sensitive.
- They can only contain alpha-numeric characters and underscores.
- No special characters are allowed.