There are five standard data types in Python. They are: numbers,string, list, tuple and dictionary. These five data types are commonly referred as the “primitive data types” in Python. In this article, we are going to see how they are using in programming in a very basic level. You can then make your codes as complex as lithosphere!!
- Store numeric values
- immutable. Changing the value of a variable would result in a creation of a new object.
- you can delete variable using the “del” statement. Now first rest come codes.
Traceback (most recent call last):
File “<tmp 3>”, line 8, in <module>
NameError: name ‘myfloatvar’ is not defined
Please notice that as the del statement deleted the myfloatvar variable, the last print statement resulted in an error.
Number types in Python:
There are again four types of numbers that can be used in Python programming.
- Plain Integers: -231 to 231 – 1, usually represented in the base 10 (decimal) format.
- Long integers: less than -231 to greater than 231 – 1. The suffix “l” or “L” at the end of any integer value denotes a long integer. Note, you don’t need to add L while declaring the variable. Python knows what type of integer it would be.
- Floating point real numbers/float: range from +10308.25 through -10308.25. Float values can have two parts, a decimal point part and an optional exponent part.
- Complex numbers: an ordered pair of real floating point numbers denoted by a + bj.
Time for some code examples:
#–>1.1 -13.5 88.9965 33000000000.0 3.3e-10