chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Interior angle sum generator filter_list
Author
Message
Interior angle sum generator #1
Coded this in 40 minutes during lunch as extra credit for math. Thats why its so commented. The bitch never "got around to it," so I'm releasing this to display the implementation of formulas in python. The formula used is 180(n-2) where n is the number of sides.
Code:
import sys
#creates a main menu
def menu():
    #writes a welcome message
    print "Welcome to my interior angle sum generator!"
    raw_input('Press any key to continue...')
    #Asks for an input to make a selection
    x = raw_input('Enter 1 for a single value \nEnter 2 for a list of values: ')
    #if the input is equal to 1 it will call the first option
    if int(x) == 1:
        individual()
    #if the input is 2 it will call the second option
    elif int(x) == 2:
        array()
    #If a number other than 1 or 2 is entered it will give an error
    else:
        print "Please enter a valid number!"
def menu2():
    x = raw_input('---------------------------\nEnter 1 for a single value \nEnter 2 for a list of values\nEnter 3 to exit: ')
    #if the input is equal to 1 it will call the first option
    if int(x) == 1:
        individual()
    #if the input is 2 it will call the second option
    elif int(x) == 2:
        array()
    #If a number other than 1 or 2 is entered it will give an error
    elif int(x) == 3:
        sys.exit('Thank you for using Int Sum Generator by Ryan Shtirmer!')
    else:
        print "Please enter a valid number!"
#creates a function for one polygon with the given number of sides
def individual():
    #asks for an input of the number of sides
    n = raw_input('Number of sides: ')
    #Checks if the input is less than 3
    if int(n) < 3:
        print "Please enter a number above 3!"
        individual()
    #Runs and displays the formula
    if n >= 3:
        x = int(n)-2
        print x * 180
        raw_input('Press any key to continue...')
    else:
        individual()
    menu2()
#Creates a function to make a list of angles sums between 3 and the inputted number
def array():
    #number of sides is 3
    n=3
    #Asks for the highest number of sides
    z = raw_input('Highest Number of sides: ')
    #Checks if the number is less than 4 or greater than 500
    if int(z) < 4:
        print "Please enter a number greater than 3!"
        array()
    if int(z) > 500:
        print "Please enter a number less than 500!"
        array()
    #Runs the formula on all numbers between 3 and the given number
    if int(z) >= 4 and int(z) <=500:
        while n<int(z):
            x=n-2
            print str(n) + ":" + str(x * 180)
            n+=1
        raw_input('Press any key to continue...')
        menu2()
    else:
        array()
menu()
#MakeSinisterlySexyAgain

Reply

RE: Interior angle sum generator #2
Sounds like that bitch is a hater bruh. Should poison her ovaries or something.

Looks useful. Thanks. Smile
I'm out. Y'all needa sense of humor. Peace.

Reply

RE: Interior angle sum generator #3
(11-07-2013, 01:58 AM)Sir Wrote: Sounds like that bitch is a hater bruh. Should poison her ovaries or something.

Looks useful. Thanks. Smile

You don't even know. I need 1 fuckin percent to get an A. And theres no grades left in the quarter.
#MakeSinisterlySexyAgain

Reply

RE: Interior angle sum generator #4
(11-07-2013, 01:59 AM)Putin Wrote: You don't even know. I need 1 fuckin percent to get an A. And theres no grades left in the quarter.

I'd speak up tbh. Idk what exactly can be done about it, but I'm sure something can?
I'm out. Y'all needa sense of humor. Peace.

Reply

Interior angle sum generator #5
(11-07-2013, 02:00 AM)Sir Wrote: I'd speak up tbh. Idk what exactly can be done about it, but I'm sure something can?

In my school absolutly nothing. She agreed to give the credit because she didn't think i could do it.
#MakeSinisterlySexyAgain

Reply






Users browsing this thread: 1 Guest(s)