6. Write a python program to all the items in a list_a as shown in the output below with their corresponding class of the items
The output is:
list_a = [1868, 2+5j, True, 'freelearningpoints', 1.52, {"Python user":123},
(2, -9), [6, 18]]
Expected Answer:
The class of 1868 is [class 'int'
The class of (2+5j) is [class 'complex']
The class of True is [class 'bool']
The class of freelearningpoints is [class 'str']
The class of 1.52 is [class 'float']
The class of {'Python user': 123} is [class 'dict']
The class of (2, -9) is [class 'tuple']
The class of [6, 18] is [class 'list']
Sample Answer:
list_a = [1868, 2+5j, True, 'freelearningpoints', 1.52, {"Python user":123}, (2, -9), [6, 18]] for i in list_a : print ("The class of ",i, " is ", type(i))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)