a blog by Brie Gordon
Brie Gordon

I'm Brie, a 22 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.

Posterous is one of my favorite new(ish) web sites!


brie@briegordon.com

       

Search

June 29th, 8:53am 0 comments

Collatz Conjecture - Python

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

April 13th, 8:18pm 0 comments

Sales Tax Calculator - Python

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: