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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/class-exercises/python-class-exercise-12.php