[Tutor] Is this correct?

Hoffmann oasf2004 at yahoo.com
Sat Apr 15 19:50:29 CEST 2006


Hello:

This question is regarding the first exercise of the
book  "How to think Like a Computer Scientist:
Learning with Python", by Downey, Elkner, and Meyers,
Chapter 13, page 137.
The goal is to write a function printTime that takes a
Time object as an argument and prints it in the form
hours:minutes:seconds.

So, I wrote the script below:

class Time:
	pass
	
hour = int( raw_input('Enter the hour: ') )
min = int( raw_input('Enter the minute: ') )
sec = int( raw_input('Enter the sec: ') )

time = Time()
time.hours = hour
time.minutes = min
time.seconds = sec

def printTime(time):
	print 'The time is %dh:%dmin:%dsec' % (hour, min,
sec)
	
printTime(time)

That seems to work, but I would like to hear from you.
Please, let me know if I am in the right way.

Thanks!
Hoffmann

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list