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)
************************************************** ************** 2 1058
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" :-)
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hugh |
last post by:
I am using python 2.3 through the PythonWin program on windows. I
would like to create a console-based interactive session. The program
raw_input is almost exactly what I'd like, except that...
|
by: J. W. McCall |
last post by:
I'm working on a MUD server and I have a thread that gets keyboard input
so that you can enter commands from the command line while it's in its
main server loop. Everything works fine except that...
|
by: dale |
last post by:
Python newbie disclaimer on
I am running an app with Tkinter screen in one thread and command-line
input in another thread using raw_input(). First question - is this
legal, should it run...
|
by: JerryKreps |
last post by:
Hi, folks --
I'm a Python pup.
As you can see from the session copied at the end of this post, I have the latest version of Python, and I've been using the Editor-Shell of the latest version of...
|
by: planetthoughtful |
last post by:
Hi All,
As always, my posts come with a 'Warning: Newbie lies ahead!'
disclaimer...
I'm wondering if it's possible, using raw_input(), to provide a
'default' value with the prompt?
I would...
|
by: Stuart McGraw |
last post by:
In the announcement for Python-2.3
http://groups.google.com/group/comp.lang.python/msg/287e94d9fe25388d?hl=en
it says "raw_input(): can now return Unicode objects".
But I didn't see anything...
|
by: oliver |
last post by:
Hey Everyone,
This is probably going to sound like a bit of a stupid question - but
why does (in the following code) the script just continue to run past
the raw_input, when the user hasn't...
|
by: Mike Kent |
last post by:
It's often useful for debugging to print something to stderr, and to
route the error output to a file using '2>filename' on the command
line.
However, when I try that with a python script, all...
|
by: Dox33 |
last post by:
I ran into a very strange behaviour of raw_input().
I hope somebody can tell me how to fix this.
(Or is this a problem in the python source?)
I will explain the problem by using 3 examples....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |