Small Logo

Robert's Technology Journal

RSS Icon

Online home of Robert V. Bolton

You are here: Home » Programming » Fighting the Flu with Python

Fighting the Flu with Python

Over the last few days I have been having flu like symptoms. This has left me either stuck in bed or very lethargic at work. Not wanting to completely waste my time I’ve been actively engaged in learning Python. Thus far I’ve gotten a few of the basics down and have been able to hack my way through a few scripts. I know I’m no where near being a master Python programer, but I am well on my way.

The Tower of Hanoi

Here is my version of the classic computer science problem about recursion.

#!/usr/bin/python
 
# Towers fo Hanoi
#
# An example program about recursion
 
def hanoi(n, a = "A", b = "B", c = "C"):
 
    """ 
    Move n discs from A to C using B as middle
    """
 
    if n == 0:
        return
    hanoi(n-1,a,c,b)
    print a, '->', c
    hanoi(n-1,b,a,c)
 
def get_disk_number():
 
    """ 
    Get the number of disk to be used with hanoi function
    """
 
    disk_number = raw_input("Enter number of disk: ")
    n = int(disk_number)
    return n
 
def main():
 
    """ 
    Main function of program
    """
 
    n = get_disk_number()
    hanoi(n)
 
if __name__ == "__main__":
    main()

My Next Project

I think for my next project I’m going to try and make a command line Twitter client. I know a the world doesn’t need a command line Twitter client, but I think this would be a good exercise in Python anyways. This is a coarse based on weather I survive the flu or not. Check back soon to find out more.

No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Google Bookmarks
  • Ping.fm
Trackbacks: http://www.robertvbolton.com/fighting-the-flu-with-python/trackback/

About Robert V. Bolton

Robert (KE7ZEA) lives with his wife and two boys along the Wasatch Front in the small community of Syracuse, Utah. He currently works for the Center for High Performance Computing at the University of Utah as a Unix/Macintosh Systems Administrator. His interest include open source software, cluster computing, and amateur radio.

One Response

  1. [...] more here: Fighting the Flu with Python Leave a [...]

Leave a Reply

Related Post

Popular Articles

Other Topics of Intrest

  • Amateur Raido

    Covering a range of amateur radio topics including radio projects, antenna design, and radio operations.

  • Apple

    All things Apple, but with more focus on the UNIX side of OS X.

  • Conferences

    Information, updates, and reviews of technology conferences that I attend.

  • Everyday Life

    Insight into the technology that effects my everyday life.

  • Fedora

    An RPM-based, general purpose operating system built on top of the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat Topics are related to my involvement with the Fedora project.

  • Programming

    A journey into the realm of computer programing. Topics can include programming languages, techniques, and theories of computation.

  • Technology

    Insight into the technology that effects our everyday life. Topics can include social media, tends in personal technology, and the effect of technology on society.