Planet Class Simulation
A beginner-friendly Python project that demonstrates Object-Oriented Programming (OOP) concepts through a Planet class.
The project models planets with attributes such as name, planet type, and star, while implementing methods to describe planetary behavior and validate data.
Features
- Create planet objects with custom attributes
- Validate input using exceptions
- Raise TypeError for invalid data types
- Raise ValueError for empty strings
- Display orbit information
- Customize object string representation using
__str__
- Practice Python OOP fundamentals
Concepts Used
- Classes and Objects
- Constructors (
__init__)
- Instance Attributes
- Methods
- Exception Handling
- Type Checking
- f-Strings
- Special Methods (
__str__)
Example Output
| Planet: Earth |
Type: Terrestrial |
Star: Sun |
Earth is orbiting around Sun…
| Planet: Venus |
Type: Terrestrial |
Star: Sun |
Venus is orbiting around Sun…
| Planet: Jupiter |
Type: Gas Giant |
Star: Sun |
Jupiter is orbiting around Sun…
Learning Outcomes
This project helped practice:
- Creating classes and instances
- Defining custom methods
- Using
self
- Returning values from methods
- Validating user input
- Understanding Python magic methods
- Debugging common OOP mistakes