G+_egbie anderson Posted April 29, 2014 Share Posted April 29, 2014 hello guys I was stumped on what to create using python then I remember what Shannon said about they being lots of examples from previous episodes. So I start watching previous episodes this is because I did not know about the show until recently. I started watching it from python series and have done a lot of catching up since then. Anyway after watching a few episodes back to back I might add I came across one episode in which Lou use C sharp to create a program that ask a user to enter a number. The number is then turned into its binary representive. So for this week homework as Shannon puts it I decided to replicate the program created. But instead of the program asking the user to input a number, the program ask the user insteads to inputs text. The text does not matter whether it be by hand, copying or pasting it from some external means. The means does not matter as long as the program gets the input . Only charactes no jpeg or the program will break. The program then turns that text in binary. You can even paste any entire text and the program will still convert it to binary. Like any other program I have included the means of converting the binary digits back into alphanumeric characters i.e letters, chars, spaces, etc. I have tested the program on both linux and windows as I have a virtual box. The only OS I have not tested is Mac but i have written it in such a way that it still will work regardless of what the operating system is. But never the less if you find a bug congrulation please let me know. The program uses everything that has been taught in the previous classes such as for loop, conditional statements, comments, try block and much much more. Although the program is very long and may seem intimidating to new user at the heart of it it quite simple to use and the code is easy to understand. The program uses abstraction ensuring that the complex is not passed on to the user. The user does not need to do anything just copy the program and run it by either pressing F5 or by running it in the idle command menu and let the program do the rest. I written the 'binary to text' in such a way that you could go to internet find a text to binary online program enter some text get the result in binary and use my program to convert it back into text. Note you do not have to alter the text after you get it from the online program. Just paste as it is. So have fun take the program apart, test it, make it better general try to break, like father Padre says that how one learns. So without further ado here my code http://pastebin.com/k9pytFSt Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 29, 2014 Share Posted April 29, 2014 Only problem I see if that you're only encoding 8 bits. Python chars are Unicode, and may take up to 21 bits to encode in binary. Link to comment Share on other sites More sharing options...
G+_egbie anderson Posted April 29, 2014 Author Share Posted April 29, 2014 thanks for the input appreciate it. Link to comment Share on other sites More sharing options...
G+_egbie anderson Posted April 30, 2014 Author Share Posted April 30, 2014 I have added a few extra comments and removing two things from the Interface class. The interface class now only inherits the operating system class. When I originally wrote the program the interface class was inheriting multiple class as I was using them as the main base. But after I re-factored the code I forgot to remove the inheritance classes from the Interface class Link to comment Share on other sites More sharing options...
Recommended Posts