w3resource

Python: Get the class name of an instance in Python

Python Class: Exercise-12 with Solution

Write a Python class to get the class name of an instance in Python.

Sample Solution:

Python Code:

import itertools
x = itertools.cycle('ABCD')
print(type(x).__name__)

Sample Output:

cycle

Flowchart:

Flowchart: Get the class name of an instance in Python

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle.
Next: Data Structures and Algorithms Home.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.