Question about output...

Dave Cole djc at
Thu Oct 17 04:28:14 CEST 2002

>>>>> "Tony" == Tony Warmath <stryder at> writes:

Tony> Hi, I'm a C++ programmer and I'm trying to pick up on Python, so
Tony> I've starting out making the same programs I have in college in
Tony> C++ except coding them in Python, and I'm already stumped. I'm
Tony> trying to produce the Python equivalent of this statement in
Tony> C++:

Tony> cout << "The average of " << firstInt << " and " << secondInt <<
Tony> " is " << average << endl;

Tony> using variables and strings in one line of output. I've seen
Tony> some FAQs but didn't like the way they said do them,
Tony> i.e. assigning a variable to the whole string. What's the Python
Tony> equivalent to that statement to get me on my way. Thanx!

>>> firstInt = 10
>>> secondInt = 20
>>> average = (firstInt + secondInt) / 2
>>> print 'The average of', firstInt, 'and', secondInt, 'is', average
The average of 10 and 20 is 15

- Dave


More information about the Python-list mailing list