Re: [Tutor] Print question in IDLE

2009-01-30 Thread Vern Ceder
I just tried it in Python 3 (both at the interactive prompt and in idle) and both places I get: >>> "food is very nice" #lets eat 'food is very nice' >>> So it looks like it *should* work. You might copy and paste exactly what you get into a post, including the full error traceso that we can s

Re: [Tutor] Print question in IDLE

2009-01-30 Thread Alan Gauld
"jims" wrote I apologize for asking such a dumb question The only dumb questions are the ones you don;t ask. Its how to learn! Simply put here is where I am stuck. (Python version 3.0) I type in the example using the comment command: (example) *>>> "food is very nice" #lets eat The >>

Re: [Tutor] Print question in IDLE

2009-01-30 Thread Eric Dorsey
At the >>> prompt (which is the interactive) interpreter, try: print('food is very nice') #lets eat On Fri, Jan 30, 2009 at 5:45 PM, jims wrote: > I apologize for asking such a dumb question but I have no prior programming > experience and am trying to learn by following examples from a book.

[Tutor] Print question in IDLE

2009-01-30 Thread jims
I apologize for asking such a dumb question but I have no prior programming experience and am trying to learn by following examples from a book. And also from the web. Simply put here is where I am stuck. (Python version 3.0) I type in the example using the comment command: (example) *>>> "f

Re: [Tutor] print question

2007-10-09 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dick Moores wrote: >> return "%02d:%02d:%5.2f" % (hours, minutes, seconds) > > Try %05.2f > > The leading 0 is a 'conversion flag' that specifies zero-padding. Sorry I should have included that in my post but I ass

Re: [Tutor] print question

2007-10-09 Thread Dick Moores
At 03:37 AM 10/9/2007, Kent Johnson wrote: >Dick Moores wrote: >> return "%02d:%02d:%5.2f" % (hours, minutes, seconds) > >Try %05.2f > >The leading 0 is a 'conversion flag' that specifies zero-padding. Huh. Thought I'd tried that. Guess not. Thanks, Kent! ___

Re: [Tutor] print question

2007-10-09 Thread Kent Johnson
Dick Moores wrote: > return "%02d:%02d:%5.2f" % (hours, minutes, seconds) Try %05.2f The leading 0 is a 'conversion flag' that specifies zero-padding. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] print question

2007-10-09 Thread Dick Moores
At 12:58 AM 10/9/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > return "%02d:%02d:%2.2f" % (hours, minutes, seconds) > > > print secsToHMS(4.04987) --> 00:00:4.05 (I wanted 00:00:04.05) > > > > I don't see how to get 00:00:04.05 using %f . > >

Re: [Tutor] print question

2007-10-09 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > return "%02d:%02d:%2.2f" % (hours, minutes, seconds) > print secsToHMS(4.04987) --> 00:00:4.05 (I wanted 00:00:04.05) > > I don't see how to get 00:00:04.05 using %f . > is as > clear as m

Re: [Tutor] print question

2007-10-08 Thread Dick Moores
Thanks, Kent and Ian. See below. At 07:30 PM 10/8/2007, Kent Johnson wrote: >> if seconds >= 60 and seconds < 3600: >> minutes, seconds = divmod(seconds, 60) >> elif seconds >= 3600: > >You don't need this conditional, just use the next two lines >unconditionally. If seconds<3

Re: [Tutor] print question

2007-10-08 Thread Ian Witham
> > > Thanks! > > So now I have > > def secsToHMS(seconds): > """ > Convert seconds to hours:minutes:seconds, with seconds rounded > to hundredths of a second, and print > """ > hours, minutes = 0, 0 > if seconds >= 60 and seconds < 3600: > minutes, seconds = divmo

Re: [Tutor] print question

2007-10-08 Thread Kent Johnson
Dick Moores wrote: > At 06:24 PM 10/8/2007, John Fouhy wrote: >> On 09/10/2007, Dick Moores <[EMAIL PROTECTED]> wrote: >>> What's the best way to get hours in 2 or more digits, and minutes in >>> 2 digits, so that the above would be 05:07:36.88? (I'm writing a >> stopwatch.) >> >> String formattin

Re: [Tutor] print question

2007-10-08 Thread Dick Moores
At 06:24 PM 10/8/2007, John Fouhy wrote: >On 09/10/2007, Dick Moores <[EMAIL PROTECTED]> wrote: > > What's the best way to get hours in 2 or more digits, and minutes in > > 2 digits, so that the above would be 05:07:36.88? (I'm writing a > stopwatch.) > >String formatting! > > >>> template = '%02d

Re: [Tutor] print question

2007-10-08 Thread Ian Witham
On 10/9/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > def secsToHMS(seconds): > """ > Convert seconds to hours:minutes:seconds, with seconds rounded > to nearest hundredths of a second, and print > """ > hours, minutes = 0, 0 > if seconds >= 60 and seconds < 3600: >

Re: [Tutor] print question

2007-10-08 Thread John Fouhy
On 09/10/2007, Dick Moores <[EMAIL PROTECTED]> wrote: > What's the best way to get hours in 2 or more digits, and minutes in > 2 digits, so that the above would be 05:07:36.88? (I'm writing a stopwatch.) String formatting! >>> template = '%02d:%02d:%02d.%02d' >>> template % (1, 22, 3, 44) '01:22:

[Tutor] print question

2007-10-08 Thread Dick Moores
def secsToHMS(seconds): """ Convert seconds to hours:minutes:seconds, with seconds rounded to nearest hundredths of a second, and print """ hours, minutes = 0, 0 if seconds >= 60 and seconds < 3600: minutes, seconds = divmod(seconds, 60) elif seconds >= 3600: