Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

class

class Planet:

    def __init__(self, name, radius, gravity, system):
        self.name = name
        self.radius = radius
        self.gravity = gravity
        self.system = system

    def orbit(self):
        return f'{self.name} is orbiting in the {self.system}'


alphax123 = Planet('alphax123', 300000, 8, 'Naboo System')
print(f'Name: {alphax123.name}')
print(f'Radius: {alphax123.radius}')
print(f'Gravity: {alphax123.gravity}')
print(f'System: {alphax123.orbit}')
 
PREVIOUS NEXT
Tagged: #class
ADD COMMENT
Topic
Name
9+8 =