470,647 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

raw_input passing to fun



the output of this code below is not what one would expect, it outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.

thanks

************************************************** **************
import math

def printMultiples(n, hight):
i = 1
while i <= hight:
print n*i, '\t',
i = i + 1
print
def printMultTable(hight):
i = 1
while i <= hight:
printMultiples(i, i)
i = i + 1

num = raw_input ("produce a multiplication table up to: ")
printMultTable(num)
************************************************** **************
Apr 28 '06 #1
2 999
On 28/04/2006 2:04 PM, Gary Wessle wrote:

the output of this code below is not what one would expect, it outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.
That's what you want, but not what you did. You asked them for a string.

thanks

************************************************** **************
import math
Not used.

def printMultiples(n, hight):
i = 1
while i <= hight:
print n*i, '\t',
i = i + 1
print
def printMultTable(hight):
i = 1
while i <= hight:
Temporarily, insert here:
print "types:", type(i), type(hight)
print "values:", i, hight
if i > 100: return
printMultiples(i, i)
i = i + 1

num = raw_input ("produce a multiplication table up to: ")
printMultTable(num)


Try this: printMultTable(int(num))

You may wish to consider changing "hight" to "height" :-)

Apr 28 '06 #2
John Machin <sj******@lexicon.net> writes:
On 28/04/2006 2:04 PM, Gary Wessle wrote:
the output of this code below is not what one would expect, it
outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.


That's what you want, but not what you did. You asked them for a string.
thanks
************************************************** **************
import math


Not used.
def printMultiples(n, hight):
i = 1
while i <= hight:
print n*i, '\t',
i = i + 1
print
def printMultTable(hight):
i = 1
while i <= hight:


Temporarily, insert here:
print "types:", type(i), type(hight)
print "values:", i, hight
if i > 100: return
printMultiples(i, i)
i = i + 1
num = raw_input ("produce a multiplication table up to: ")
printMultTable(num)


Try this: printMultTable(int(num))

You may wish to consider changing "hight" to "height" :-)


thank you
Apr 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hugh | last post: by
2 posts views Thread by J. W. McCall | last post: by
reply views Thread by dale | last post: by
21 posts views Thread by planetthoughtful | last post: by
17 posts views Thread by Stuart McGraw | last post: by
6 posts views Thread by oliver | last post: by
8 posts views Thread by Dox33 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.