Thread: Python program

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    2
    Rep Power
    0

    Python program


    I am having trouble trying to decipher how to write a program in Python. The first thing is calculating the volume and surface area of a sphere from it radius, given as input. The formulas are V=4/3pir^3 and A=4pir^2. Thanks
  2. #2
  3. No Profile Picture
    Brony & F/OSS Advocate
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2003
    Location
    Anaheim, CA (USA)
    Posts
    6,653
    Rep Power
    2476
    Moved from the PHP Development forum.
    ~~ Peter ~~ :: ( Who am I? ) :: ( Peter's Musings: Uploading myself, bit by bit... ) :: ( Electronic Frontier Foundation ) :: ( I'm a GNU/Linux addict and Free Software Advocate. ) :: ( How to Ask Questions the Smart Way ) :: ( The Fedora Project, sponsored by Red Hat ) :: ( GNOME: The Free Software Desktop Project ) :: ( GnuPG Public Key ) :: ( About me on the WIki )
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13

    Question


    Originally Posted by jarchambo
    I am having trouble trying to decipher how to write a program in Python. The first thing is calculating the volume and surface area of a sphere from it radius, given as input. The formulas are V=4/3pir^3 and A=4pir^2. Thanks
    open a file and type:

    import math
    radius = raw_input("what is the radius? ")
    volume = ((4/3.0)*math.pi*(radius**3))
    area = (4*math.pi*(radius**2))

    print "The volume is: ", volume
    print "The area is: ", area
    raw_input("Press button to continue...")

    save the file with a .py extension and run it.
  6. #4
  7. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    Homework?

IMN logo majestic logo threadwatch logo seochat tools logo