[Tutor] Order Of Operations Question

David Hutto smokefloat at gmail.com
Wed Jul 28 11:41:48 CEST 2010

>From a practice exercise in Building Skills In Python page 64 I'm
working on How Much Does The Atmosphere Weigh? Part 1:
To check it states that the answer should be app. 10**18kg However,
and I've checked to make sure that the math I've layed out matches up
with the texts, I get 5.07360705863e+20

In the code I have broken the order of operations down to more
parenthetical, and tried outright, but see nothing obvious about how
it's strung together. If anyone has had a similar experience with the
problem given, or see anything blatantly obvious I've done wrong with
the ordering of operations. I tried to include as much of the
problem(formulas are just above variables they're used in) as comments
as possible.

import math
def atmosphereWeight():
    pi = math.pi
    """Air Pressure (at sea level) P0. This is the long-term average.
    P0 = 1.01325 × 10**5"""
    airPressCLevl = 1.01325*(10**5)
    gravity = 9.82
    """We can use g to get the kg of mass from the force of air
pressure P0. Apply the acceleration of gravity
    (in m/sec2) to the air pressure (in kg · m/sec2). This result is
mass of the atmosphere in kilograms per
    square meter (kg/m2).
    Mm2 = P0 × g"""
    masAtmoInKgPerSqM = airPressCLevl * gravity
    """Given the mass of air per square meter, we need to know how
many square meters of surface to apply
    this mass to. Radius of Earth R in meters, m. This is an average
radius; our planet isn’t a perfect sphere.
    R = 6.37 × 10"""
    avgRadiusEarth = 6.37 * (10**6)
    """The area of a Sphere.
    A = 4πr2"""
    areaSphere = 4 * pi * (avgRadiusEarth**2)
    """Mass of atmosphere (in Kg) is the weight per square meter,
times the number of square meters
    Ma = P0 × g × A"""
    masEarthAtmoInKgPerSqM = airPressCLevl * gravity * areaSphere



More information about the Tutor mailing list