Data Types In Python

Watch video presentation here ad remember to subscribe to our channel;

Watch now!

Data type– refers to the type of data. Data types are very vital in any programming language, there are various types of data types in python which are in-built which are set when one assigns value to variable. Remember you can print the type of data type by using type() they may include;

  • Numbers -Number data type in python is used to represent the numeric data, they may include complex numbers, integers and floating numbers, but in python they are represented as complex, int and float respectively.
y = 30 #int

z = 25.5 #float


  • Boolean -Boolean data type in python are represented by the true and false, example of a Boolean data type is bool.
y = false
  • Text -this type of data type is used to represent a string in python, it is represented as str which may be combination of characters and numbers. Example of this data type is a word or a sentence.
x = "We are learning data types in python"

  • Binary -this kind of data type is used to represent the binary data in python, example of binary data type includes; bytes, memoryview and even bytearray.
y = bytearray(8)

y = memoryview(bytes(10))
  • Sequence -this data type allows one to store many values in a more organized way, they include; range, tuple, list
x = ["html", "javascript", "python"]

x = range(6)
  • Set -this type of data may be represented by set or frozenset
y = frozenset({"html", "javascript", "python"})

Remember the above examples given you ca just use type() to get type of the data type in python. you can also set specific data type as shown in the following examples;

y = str("We are learning data types in python")

z = float(30.25)

x = complex(2k)

y = dict(country="kenya" age="23")

x = list(("html", "javascript", "python"))

Thanks for reading through our tutorial, hope now you understand various types of data types in python. As we continue learning about python hoping to meet you in our next tutorial.