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:
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.
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://w3resource.com/python-exercises/class-exercises/python-class-exercise-12.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics