Created
October 10, 2023 02:13
-
-
Save ApexExpress/d260f6be4198bd2f8b57751f3399baa6 to your computer and use it in GitHub Desktop.
explain the universe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Universe: | |
def __init__(self, age, size, galaxies): | |
self.age = age # Age of the universe in years | |
self.size = size # Size of the universe in cubic meters | |
self.galaxies = galaxies # List of galaxies in the universe | |
def expand(self, expansion_rate): | |
# Simulate the expansion of the universe | |
self.size *= (1 + expansion_rate) | |
def create_galaxy(self, name, stars): | |
# Create a new galaxy and add it to the universe | |
galaxy = Galaxy(name, stars) | |
self.galaxies.append(galaxy) | |
class Galaxy: | |
def __init__(self, name, stars): | |
self.name = name # Name of the galaxy | |
self.stars = stars # Number of stars in the galaxy | |
def describe(self): | |
# Describe the galaxy | |
print(f"Galaxy: {self.name}") | |
print(f"Number of Stars: {self.stars}") | |
# Create the universe | |
our_universe = Universe(age=13800000000, size=3.5e80, galaxies=[]) | |
# Expand the universe | |
our_universe.expand(expansion_rate=0.0001) | |
# Create a few galaxies | |
our_universe.create_galaxy("Milky Way", stars=200000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment