Python Programming

Discussion in 'Computing, Science, and Technology' started by LuffyZoro, Mar 30, 2010.

  1. LuffyZoro

    LuffyZoro New Member

    Joined:
    Jun 4, 2009
    Messages:
    224
    Likes Received:
    1
    Device:
    3G iPod touch
    I decided to make a simple calculator/Fibonacci Sequence python program, and try to get it as small as possible. But, I've hit a wall at 19 lines and 587 bytes. I don't want to get rid of any functionality, like error handling.
    Code:
    try:
        def menu():
                global loop
                loop = input("Enter 1 for the calculator, 2 for the Fibonacci sequence, or 3 to quit: ")
        menu()
        while loop < 3:
            def fib(n):
                a, b = 1, 1
                while n >= 1:
                    print a
                    a, b, n = b, a+b, n-1
            while loop == 2:
                fib(input("\nWhat Fibonacci number do you want to go to? "))
                menu()
            while loop == 1:
                print input("\nPut in an equation: ")
                menu()
    except:
        print "\nWhat? I don't understand."
    Can anyone help?

Share This Page