[tutor] Do I need to have a strong math skills to program

Ibraheem Umaru-Mohammed iumarumo@eidosnet.co.uk
Fri Nov 8 10:54:02 2002


* Danny Yoo <dyoo@hkn.eecs.berkeley.edu> [2002-11-08 08:44]:
> On Sun, 3 Nov 2002, Dan Dud wrote:
> 
> > Hope everyone weekend is going great. I working through the "how to
> > think like a computer scientist" I'm stuck on the part which you have to
> > define a hypotenuse triangle. I don't have a lot of math skills. Do I
> > have to have a lot of math skills to be good at programming??? I've
> > decided to skip that part and move on. I hope everyone weekend is going
> > great and I'll talk to you all soon...
> 
> Hi Dan,
> 
> I just wanted to jump back into this question because it's such a fun one
> to revisit.  *grin* There are some advantages for knowing math: with some
> math knowledge, we can make analogies between computer techniques and math
> techniques.
> 
> Warning: this message is very long, and halfway though, I just completely
> lose my head and jump into calculus.  I didn't mean to; it just happened!
> *grin* You can read up to the middle, and stop there.  But for those
> who've taken an introductory course in calculus... I dunno, maybe this
> will amuse you.
> 
> 
> Here's one problem in particular that shows a particular technique that's
> works with both computers and maths.  Let's say that we had a number, and
> we'd like to turn it into a string.  How hard would it be to transform
> that string into a integer?
> 
> (A quick solution would use the string() built-in function, since it knows
                                  ^^^^^^^^
This should be str().

And, although we have a singleNumberToString function, 
I would handle the number 0 in the turnNumberIntoString 
function, just to be consistent with:

	turnNumberIntoString(1)
	turnNumberIntoString(2)
		.
		.
	turnNumberIntoString(9)

[...]
> 
> ###
> >>> def turnNumberIntoString(number):
> ...     characters = []
	  if number == 0: return '0'	
> ...     while number != 0:
> ...         next_digit = number % 10
> ...         next_character = singleNumberToString(next_digit)
> ...         characters.append(next_character)
> ...         number = number / 10
> ...     characters.reverse()
> ...     return ''.join(characters)
> ...
> >>> turnNumberIntoString(12345)
> '12345'
> ###
> 
[...]

Thanks for the post, an informative and enjoyable read.

			--ibz.