Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
SumFinder
  • chroniccommand
    Posts: 1,389
    Here is a simple script I've written in Python. I figured I'd implement what I've been learning in my geometry class with my learning of OOP in Python. It gets the sum of the interior angles of a polygon. Lets say I have an octogon:

    [chronic@vandal src]$ python main.py
    Number of sides: 8
    1080



    #!/usr/bin/env python
    '''
    Simple tool written in Python to help find the sum of interior angles of a regular polygon
    Formula:
    180(n - 2) where n is the number of sides
    '''
    import sys
    class DoMath(object):
    def __init__(self, n):
    self.sides = n
    def GetSum(self):
    number = self.sides - 2
    answer = 180 * number
    print answer
    try:
    n = int(raw_input(\"Number of sides: \"))
    except ValueError:
    print(\"Value not correct\")
    sys.exit()
    initmath = DoMath(n)
    initmath.GetSum()
  • Xin
    Posts: 3,251
    Nice little program good job.
    Xin
  • undead
    Posts: 822
    I remember when we learned that a while ago. Nice work!