Debug: Database connection successful Python Computer Language (Page 4) / Science, Technology, and Astronomy / New Mars Forums

New Mars Forums

Official discussion forum of The Mars Society and MarsNews.com

You are not logged in.

Announcement

Announcement: This forum is accepting new registrations via email. Please see Recruiting Topic for additional information. Write newmarsmember[at_symbol]gmail.com.

#76 Today 04:10:22

offtherock
Member
Registered: 2017-10-26
Posts: 29

Re: Python Computer Language

If u want i could write say, class planet,
and u could tell me what its attributes are:
Radius, mass, density ..

And which member functions it needs to have. Maybe:
get_diameter()
get_surface_area()
..

something like that.

Could be as much about learning as it is about doing the programming.

Last edited by offtherock (Today 04:11:02)

Online

Like button can go here

#77 Today 05:52:10

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 22,320

Re: Python Computer Language

For offtherock ... Thank you for your interest in converting the Python program to object style!

Everything needed should be available in the existing program.   The equations may have to be changed to account for the new style.

At present, the mass of the Earth is stored in the form of a variable that is then employed in the equations as needed.

If object style is used, then the property of mass must be delivered to the question in a compact form.

***
For all... Version 15 is in a development phase.  The process to model Flow of thermal energy from hot gas to cold metal is not yet working.  Today I'm planning to work with Gemini to improve the flow.  My guess is that we do not yet have a material defined for the container wall, so we do not have properties of that material to work with, such as thermal conductivity.

In the course of this investigation I am hoping to learn about thermal energy transfer by direct contact (conduction). 

(th)

Offline

Like button can go here

#78 Today 06:23:19

offtherock
Member
Registered: 2017-10-26
Posts: 29

Re: Python Computer Language

I downloaded the program and ran it.

You can add

###
from modules.planet import Planet
earth = Planet('Earth');

earth.g_constant = 6.67430e-11
earth.mass = 5.972e24
earth.radius = 6.371e6
earth.sea_level_density = 1.225
# Gravitational constant (N * m^2 / kg^2)
# Default units are kg and meters.
###

right beneath the first 3 import lines.
But u need to make a folder called modules.
and in that folder, place file planet.py and put in that file:

class Planet:
    def __init__(self, name):
        self.name = name

    def set_mass(self,new_mass):
        self.mass = new_mass

Online

Like button can go here

Board footer

Powered by FluxBB