Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # either_instance.py
- class Square:
- pass
- class Circle:
- pass
- class Triangle:
- pass
- def detect_shape(shape):
- if isinstance(shape, (Square, Circle)):
- print("It's either a Square or a Circle.")
- # Your further logic goes here
- else:
- print("It's NOT a Square or a Circle.")
- # Example usage
- square_instance = Square()
- circle_instance = Circle()
- triangle_instance = Triangle()
- detect_shape(square_instance) # Output: It's either a Square or a Circle.
- detect_shape(triangle_instance) # Output: It's NOT a Square or a Circle.
- detect_shape(circle_instance) # Output: It's either a Square or a Circle.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement