Rough Python Raspberry Pi Code