Python Data types and type

Charles Butler Jr
2 min readSep 10, 2021

In my continuing trek down the python rabbit hole, this week i’ve been studying data types and manipulating them within python. Python like many other languages has multiple data types some familiar and some a bit new to me but all important in the study of utilizing these in data structure & algorithm problems.

Common datatypes like strings, booleans, integers and floats I’ve been used to in other languages but new ones that have replaced array’s and hashes are lists, tuples, dicts, sets and frozen-sets. For my first exercise we are utilizing the type method (along with print) to analyze input’s and see what data type is contained in the variable.

Setting x as a string “Hello World” & passing it into the print function we can utilize the ‘type’ method and inquire what x is… we should return the class of ‘str’ for string.

Repeated with changing the variable value to a float and the class reflects it as well. This helps with any if statements specifying checks for certain data types and if they’ll pass on to another block of code.

--

--

Charles Butler Jr

Pre-Med student turned software engineer. Hoping to make code make sense & make sense out of all my code.