tag:blogger.com,1999:blog-7933794355391496434.post36367732054047834..comments2023-06-03T06:26:18.614-06:00Comments on A Million Chimpanzees: Python: Converting from one temperature scale to another is easy, but what about eight?james.pyleshttp://www.blogger.com/profile/11424800834517755783noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7933794355391496434.post-4833115758605585132009-10-12T11:51:14.346-06:002009-10-12T11:51:14.346-06:00Helpful comments are welcome. Snarky comments are ...Helpful comments are welcome. Snarky comments are still tolerated because I'm such a nice guy. ;-)james.pyleshttps://www.blogger.com/profile/11424800834517755783noreply@blogger.comtag:blogger.com,1999:blog-7933794355391496434.post-10845359293042277622009-10-12T11:47:01.371-06:002009-10-12T11:47:01.371-06:00A pointless exercise in simple programming - just ...A pointless exercise in simple programming - just as pointless most of those temperature scales have become.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7933794355391496434.post-58233082930651304692009-10-12T05:13:51.807-06:002009-10-12T05:13:51.807-06:00How about
cel = (t - 32) * 5.0 / 9.0
instead of
ce...How about<br />cel = (t - 32) * 5.0 / 9.0<br />instead of<br />cel = (t - 32) + 5.0 / 9.0<br /><br />Personally, I also think that if you want to teach a problem of this scale (to & from 8 temperatures) to a newbie, then you're not primarily giving him/her a python excercise, but a programming excercise. That is a good occasion to teach them not to do it using a large, long-to-type, hard-to debug, etc. list of copy-paste-edited if/then/else, but using lookup in table. The code then collapses to only a few lines (excluding I/O), and adding another temperature scale only adds one single line to the table, while the code remains unchanged (assuming the scale is linear)Anonymousnoreply@blogger.com