# this file available at: https://arachnoid.com/files/python01/ # type: ignore # See https://www.w3schools.com/python/python_datatypes.asp def show_type(x): # argument -> string for easier formatting ds=f'{x}' if ds =='True': ds = 'True|False' # acquire type string ts = type(x).__name__ if ts == 'str': ts = 'string' if ds == 'nan': ts = 'float (Not a Number)' print(f'{ds:<42} : {ts}') data_types = ( True, 5, 5.678, float("nan"), 3+4j, '"text"', b"text", bytearray(3), memoryview(bytes(3)), show_type, [1,2,3], (1,2,3), {1,2,3}, frozenset({1,2,3}), {'key1':'value1','key2':'value2'}, range(5), None ) def main(): print('Python Data Types\n') print(f'{"Example":<42} : Type') print('-' * 60) for x in data_types: show_type(x) print() print('Data in a [list] can be changed.') print('Data in a (tuple) cannot be changed.') print('Data in a {set} are unique / have no duplicates.') print('Data in a {frozenset} cannot be changed.') print('{ keys : values } in a dict can be nearly anything.') if __name__ == "__main__": main()