[Tutor] Help!

Joel Goldstick joel.goldstick at gmail.com
Mon Jan 28 23:17:19 CET 2013


On Mon, Jan 28, 2013 at 4:51 PM, Danny Yoo <dyoo at hashcollision.org> wrote:

> > Hi guys I wanted to make a program called Binary/decimal converter. But
> I want to do it the hard way e.g. not using built in python functions. Can
> you give me an idea about how I can do that?
>
>
> See if you can write the steps to do this by hand.  You take binary
number -- say 10110 and convert it to decimal.  If you can do that with pad
and pencil, you are off to a good start.  If you can't, then you have to
learn that first.  Its not magic.  Learning about bit shifting will help



> Do you have an idea of what kind of things would be useful test cases
> for this converter?  Thinking about this may help solidify what it is
> you're trying to do.  By it, we want to help you express concretely
> what you mean when you say "binary/decimal converter".
>
> ---
>
> For example, if I wanted to write a program to convert "snow" to
> "water", I might start like this:
>
> I want to write a program to take words like "snow" and rewrite them
> to "water".  But anything else should stay the same.  Let me give a
> name to this.  Call it "melt".  Here are some examples I'd like to
> make work (or not work).
>
>     melt("The snow is cold!")  ==> "The water is cold!"
>     melt("The snowflakes are falling") ==>  "The snowflakes are falling"
>     melt("Snow and ice") ==>  "Water and ice"
>
> That is, I want to make sure the translation is case sensitive, but
> only applies when the whole word "snow" shows up.
>
>
> ... etc.  A potential approach might use regular expression
> replacement, with a little bit of care about using a function for the
> replacement argument so we can handle the weird uppercasing
> requirement...
>
> ---
>
>
> If you plan like this, and include concrete test cases, then you'll
> have a better shot at solving the problem.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130128/0d27855c/attachment-0001.html>


More information about the Tutor mailing list