a blog by Brie Gordon

...and nothing more

  • Collatz Conjecture - Python

    • 29 Jun 2010
    • 1 Response
    •  views
    • collatz collatz conjecture math mathematics programming python
    • Edit
    • Delete
    • Tags
    • Autopost

    Using Wikipedia’s pseudocode description of the Collatz Conjecture, I whipped something up in Python. Try it!


    n = int(input("What number would you like to explore? "))
    while n > 1:
         print(n)
         if n % 2 != 0:
             n = 3*n + 1
         else:
             n = n/2
    print(n)

     

    --

    Brie

    • Tweet
  • Sales Tax Calculator - Python

    • 13 Apr 2010
    • 1 Response
    •  views
    • calculator newbie programming python python development sales tax
    • Edit
    • Delete
    • Tags
    • Autopost

    Python is a very cool programming language that I've started learning. It's extremely powerful and I've already done some neat stuff with it. I wrote an interactive sales tax calculator for PA residents. (I'm working on a version that will let you tell me what state you are in and output the information appropriately.

    # This is actually the cost of the item and the tax. This would be a ridiculous tax rate.
    tax = 1.07
    price = raw_input("How much is your item before tax? ")
    totalcost = float(price) * float(tax)
    finalanswer = round(totalcost, 2)
    print finalanswer

    Here's a screenshot of how it works:

    • Tweet
  • About

    I'm Brie, a 23 year-old graduate of Slippery Rock University's Computer Science department. My interests include Linux (generally and Ubuntu), networking, BSD-style operating systems including my own, BrieSD, translating English-Spanish-English for open source projects and LAMP configuration. Aside from that, I enjoy photography, making short films and soccer.



    web@briegordon.com

    62592 Views
  • Archive

    • 2011 (4)
      • August (2)
      • June (1)
      • February (1)
    • 2010 (5)
      • December (1)
      • October (1)
      • June (1)
      • April (2)
    • 2009 (8)
      • December (4)
      • November (1)
      • October (2)
      • July (1)

    Get Updates

    Subscribe via RSS
    TwitterLaconi.ca/Identi.caPlurkJaiku