Thank you guys On Mon, Nov 3, 2014 at 11:26 PM, Alan Gauld <alan.ga...@btinternet.com> wrote:
> On 03/11/14 18:04, William Becerra wrote: > > def printMultiples(n, high): >> i = 1 >> while i<=high: >> print n*i, "\t", >> i = i + 1 >> print >> > > def multipleTable(high): >> i = 1 >> while i<=high: >> printMultiples(i, i) >> i = i + 1 >> print >> > > print multipleTable(6) >> >> when i run this code the result i get is >> >> 1 >> 2 4 >> 3 6 9 >> 4 8 12 16 >> 5 10 15 20 25 >> 6 12 18 24 30 36 >> > > Can someone please explain why does it print a triangular table and not >> a square table like this one: >> > > Because you call print Multiples() from within multipleTable() > Each time the loop executes the value of i increases so each line printed > gets longer. The first line is printed by printMultiples(1,1) > The second is called with printMultiples(2,2) and so on up to > printMultiples(6,6). > > This yields a triangular printout. > > is there any documentation i can read on tables? >> > > Not really, there's no such thing as a table in Python programming, its > just a structure you create. In practice its usually composed of a list of > lists. > > HTH > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.flickr.com/photos/alangauldphotos > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor