Type
Type is a collection of rules for constructs such as variables and functions. Untyped languages allow any operation to be performed on any data type.
Static vs. Dynamic
Strong vs. Weak
Language Examples
C: Weak Static
C++: Weak Static
Java: Strong Static
JavaScript: Weak Dynamic
Perl: Weak Dynamic
Python: Strong Dynamic
Ruby: Strong Dynamic
Python Example
Details on Python types can be found here.
Main Python types include:
numerics
int
float
complex
sequences
list - mutable, defined with [ ]
tuple - immutable, defined with ( )
range - defined with range( )
str - define with “ “ or ‘ ‘
binary
bytes
bytearray
mappings
dict - defined with { }
classes
instances
exceptions
# An example of a type() function return value is: <type 'str'> # Determine the type of a variable. variable_example = "A test string." variable_type = type(variable_example) print(variable_type)