Beispiel #1
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

naboo = Planet()

planet_mass()
Beispiel #2
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

naboo = Planet("Naboo", 300000, 8, "Naboo Sytem")

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volume of {naboo_vol}')

Beispiel #3
0
# hf = Planet('Hanfan', 200, 5.5, 'Hanfan system')
#
# print (f'Name is: {hf.name}')
# print (f'Radius is: {hf.radius}')
# print (f'Gravity is: {hf.gravity}')
#
# # orbit() is instance method, which is only has to be from the instance
# print (hf.orbit())
#
#
# print (Planet.shape)
#
# # commons() is class method, can be accessed by Planet (can be used on the class itself)
# print (Planet.commons())
# print (hf.commons())
#
# # spin() is static method, can be accessed by Planet (can be used on the class itself)
# print (Planet.spin('a very high speed'))
# print (hf.spin('a very high speed'))

from space.planet import Planet

from space.calc import planet_mass, planet_vol

hf = Planet('Hanfan', 200, 5.5, 'Hanfan system')

hf_mass = planet_mass(hf.gravity, hf.radius)
hf_vol = planet_vol(hf.radius)

print(f'{hf.name} has a mass of {hf_mass} and a vol of {hf_vol}.')
Beispiel #4
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

planet = Planet('Andy', 5000, 4.5, 'The system')

planet_mass = planet_mass(planet.gravity, planet.radius)
planet_vol = planet_vol(planet.radius)

print(
    f'{planet.name} has  a mass of {planet_mass} and a volume of {planet_vol}')
Beispiel #5
0
from space.planet import Planet
from space.calc import planet_vol, planet_mass

naboo = Planet('Tierra', 300000, 8, 'Solar system')

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(naboo_mass)
print(naboo_vol)
Beispiel #6
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

naboo = Planet('Naboo', 300000, 8, 'Naboo System')

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volume of {naboo_vol}')
Beispiel #7
0
from space.planet import Planet  # importing the class Planet from planet file inside package
from space.math import planet_mass, planet_volume

Earth = Planet("Earth", 777, 10, "Milky way")

Earth_Mass = planet_mass(Earth.gravity, Earth.radius)

Earth_Volume = planet_volume(Earth.radius)

print("Earth Mass is : " + str(Earth_Mass))

print("Earth Volume is :" + str(Earth_Volume))
Beispiel #8
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

hoth = Planet('Hoth', 200000, 5.5, 'Hoth System')
naboo = Planet('Naboo', 300000, 8, 'Naboo System')

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volumn of {naboo_vol}.')
Beispiel #9
0
#import package from space folder
#planet is a class name from space
from space.planet import Planet
#import calc.py
from space.calc import planet_mass, planet_vol

allisa = Planet('allisa', 400000, 9.0, 'allisa system')

allisa_mass = planet_mass(allisa.gravity, allisa.radius)
allisa_vol = planet_vol(allisa.radius)

print(
    f'{allisa.name} has a mass of {allisa_mass} and a volume of {allisa_vol} ')
Beispiel #10
0
from space.planet import Planet
from space.calc import planet_mass,planet_vol

naboo=Planet("Naboo",3000000,8,'Naboo System')

naboo_mass=planet_mass(naboo.gravity,naboo.radius)
naboo_vol=planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volume of {naboo_vol}')
Beispiel #11
0
# FROM planet MODULE WITHIN THE SPACE PACKAGE IMPORT PLANET CLASS

from space.planet import Planet

# import the calc module

#import the planet_mass method and planet_vol methods

from space.cal import planet_mass, planet_vol

# NOW WE CAN CREATE A NEW INSTANCE OF THE PLANET HERE

mercury = Planet('Mercury', 444444, 8.9, 'Solar System')

# INVOKE THOSE METHODS

mercury_mass = planet_mass(mercury.gravity, mercury.radius)

mercury_vol = planet_vol(mercury.radius)

print(f'The mass of {mercury.name}is : {mercury_mass}')

print(f'The volume of {mercury.name} is : {mercury_vol}')
Beispiel #12
0
from space.planet import Planet
from space.calc import planet_mass
from space.calc import planet_vol

x = Planet(name='Troy')

juan_mass = planet_mass(x.gravity, x.radius)
juan_vol = planet_vol(x.radius)

print(f'Name is {x.name} has a mass of {juan_mass} and a volume of {juan_vol}')
# print(juan_planet.orbit())
# print(juan_planet.shape)

# plantX = Planet()
# print(plantX.commons())
# print(plantX.spin(5000))
Beispiel #13
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

nabboo = Planet('Nabboo', 3300000, 8, 'Nabboo system')

nabboo_mass = planet_mass(nabboo.gravity, nabboo.radius)
nabboo_vol = planet_vol(nabboo.radius)

print(f'{nabboo.name} has a mass of {nabboo_mass} and a volume of {nabboo_vol}')






Beispiel #14
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

# create an instance of class "Planet"
naboo = Planet('Naboo', 300000, 8, 'Naboo System')

# print out
print(f'Name: {naboo.name}')
print(naboo.spin('1000 miles per second'))

# calculation
naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)
print(f'{naboo.name} has a mass of {naboo_mass} and a volumn of {naboo_vol}')
Beispiel #15
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

maher = Planet('maher', 200000, 5.5, 'Maher System')
# print(f'Name is :{maher.name}')
# print(f'Radius is : {maher.radius}')
# print(f'The gravity is {maher.gravity}')
# print(maher.orbit())
maher_mass = planet_mass(maher.gravity, maher.radius)
maher_vol = planet_vol(maher.radius)

print(f'{maher.name} has a mass of {maher_mass} and volume of {maher_vol} ')
# planetX= Planet('planetX',300000,8,'X System')
# print(f'Name : {planetX.name}')
# print(f'Radius : {planetX.radius}')
# print(f'Gravity : {planetX.gravity}')
# print(planetX.orbit())
# print(planetX.commons())
# print(planetX.spin('a very high speed'))
Beispiel #16
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

mars = Planet('Mars', 300000, 8, 'Mars System')

mars_mass = planet_mass(mars.gravity, mars.radius)
mars_vol = planet_vol(mars.radius)

print(f'{mars.name} has a mass of {mars_mass} and a volume of {mars_vol}')
'''
class Planet:

	shape = 'round' #class level attr

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

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

	#class method: common for all our planets (class level attr)	
	@classmethod
	def commons(cls):
		return f'All planets are {cls.shape} because of gravity'

	#static method: has no to class level attr,only has access to parameters we pass individually
	@staticmethod
	def spin(speed = '2000 miles per hour'):
Beispiel #17
0
# 'space' is the folder name, 'planet' is the name of the class file.
# this is enabled by the "__init___.py" file in the space directory
from space.planet import Planet

# importing specific functions in the 'calc' file.
from space.calc import planet_mass, planet_vol

naboo = Planet('Naboo', 300000, 8, 'Naboo System')

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volume of {naboo_vol}')

print(naboo.shape)
print(Planet.shape)

print(f'default: {naboo.spin()}')
print(f'custom: {naboo.spin("100 mph")}')
print(f'custom: {Planet.spin("100 mph")}')

print(naboo.commons())
Beispiel #18
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

naboo = Planet('Naboo', 3200000, 7.5, 'Nabooo System')

naboo_mass = planet_mass(naboo.gravity, naboo.radius)
naboo_vol = planet_vol(naboo.radius)

print(f'{naboo.name} has a mass of {naboo_mass} and a volume of {naboo_vol}')
Beispiel #19
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

hoth = Planet('LEE', 20000, 5.6, 'HOHOHO')

hoth_mass = planet_mass(hoth.gravity, hoth.radius)
hoth_vol = planet_vol(hoth.radius)

print(f'{hoth.name} has a mass of {hoth_mass} and volume of {hoth_vol}')
Beispiel #20
0
from space.planet import Planet
from space.calc import planet_mass, planet_vol

earth = Planet('Earth', 20000000, 8, 'Solar')

earth_mass = planet_mass(earth.gravity, earth.radius)
earth_vol = planet_vol(earth.radius)

print(f'Earch has a mass like {earth_mass:.10f} and a vol like {earth_vol}')