Class: Nebula
Attributes: - Name (string): the name of the nebula - Type (string): the type of the nebula (e.g., emission, reflection, dark, planetary) - Size (float): the size of the nebula in light-years - Distance (float): the distance of the nebula from Earth in light-years - Composition (string): the composition of the nebula (e.g., hydrogen, helium, dust particles) - Description (string): a brief description of the nebula
Methods: - init(name, type, size, distance, composition, description): initializes the attributes of the nebula class - get_name(): returns the name of the nebula - get_type(): returns the type of the nebula - get_size(): returns the size of the nebula - get_distance(): returns the distance of the nebula from Earth - get_composition(): returns the composition of the nebula - get_description(): returns the description of the nebula - set_name(name): sets the name of the nebula - set_type(type): sets the type of the nebula - set_size(size): sets the size of the nebula - set_distance(distance): sets the distance of the nebula from Earth - set_composition(composition): sets the composition of the nebula - set_description(description): sets the description of the nebula
Example usage:
Creating a nebula object
orion_nebula = Nebula(“Orion Nebula”, “Emission”, 24, 1350, “Hydrogen, Helium, Dust Particles”, “The Orion Nebula is a diffuse nebula situated in the Milky Way, being south of Orion’s Belt in the constellation of Orion.”)
Accessing attributes
print(orion_nebula.get_name()) # Output: Orion Nebula print(orion_nebula.get_type()) # Output: Emission print(orion_nebula.get_size()) # Output: 24 print(orion_nebula.get_distance()) # Output: 1350 print(orion_nebula.get_composition()) # Output: Hydrogen, Helium, Dust Particles print(orion_nebula.get_description()) # Output: The Orion Nebula is a diffuse nebula situated in the Milky Way, being south of Orion’s Belt in the constellation of Orion.
Modifying attributes
orion_nebula.set_name(“Great Orion Nebula”) orion_nebula.set_type(“Reflection”) orion_nebula.set_size(30) orion_nebula.set_distance(1500) orion_nebula.set_composition(“Hydrogen, Helium, Dust, and Ionized Gases”) orion_nebula.set_description(“The Great Orion Nebula, also known as M42, is a reflection nebula located in the constellation of Orion. It is one of the most studied objects in astronomy.”)
Accessing modified attributes
print(orion_nebula.get_name()) # Output: Great Orion Nebula print(orion_nebula.get_type()) # Output: Reflection print(orion_nebula.get_size()) # Output: 30 print(orion_nebula.get_distance()) # Output: 1500 print(orion_nebula.get_composition()) # Output: Hydrogen, Helium, Dust, and Ionized Gases print(orion_nebula.get_description()) # Output: The Great Orion Nebula, also known as M42, is a reflection nebula located in the constellation of Orion. It is one of the most studied objects in astronomy.
Loading...