Create Different Datatypes in Tuple

Create different datatypes in tuple. The classification or categorising of data objects is known as data types. It denotes the kind of value that specifies which operations may be done on a given set of data. Data types are essentially classes, and variables are instances of these classes, because everything in Python programming is an object.

Create Different Datatypes in Tuple

A list in Python can contain a variety of data types. Each item in the list is separated by a comma, and the entire list is enclosed in square brackets. There are no inherent issues with a list containing several data types. Of course, if you try to use that list for something that wants all of the items to be of the same type, you’ll run into issues. 

Lists are mutable data types in Python because the list’s elements can be updated, individual elements can be replaced, and the order of the elements can be changed after the list has been constructed.

Tuples and How to Create a Data Types

Tuples are a type of variable that allows you to store many things in a single variable. Tuple is one of Python’s four built-in data types for storing collections of data; the other three are List, Set, and Dictionary, all of which have various features and applications. A tuple is a collection of items that is both ordered and immutable. Using this program we can execute create different datatypes in tuple.

tuplea = ("tuple", False, 45.2, 100)
print(tuplea)

Output:

(‘tuple’, False, 45.2, 100)