Re: [Tutor] Calculate hours

2013-01-25 Thread Peter Otten
शंतनू wrote: > s = [sum(x) for x in matrix] > for q in sorted([(x,y) for x,y in enumerate(s)], > key=operator.itemgetter(1)): > print("Employee %d has worked %d hours" % (q[0], q[1])) A minor simplification: s = (sum(x) for x in matrix) for q in sorted(enumerate(s), key=operator.itemgetter(

Re: [Tutor] Calculate hours

2013-01-25 Thread शंतनू
Reply inline. On 23/01/13 8:22 AM, anthonym wrote: > Hello All, > > I originally wrote this program to calculate and print the employee > with the most hours worked in a week. I would now like to change this > to calculate and print the hours for all 8 employees in ascending order. > > The employ

Re: [Tutor] Calculate hours

2013-01-23 Thread anthonym
Thanks Dave. I forgot to hit the reply to all last time. I am going to try the loop when I get back home and will let you know how I make out. Also we have done some functions. Sort and append being among them. I try the simplest way first then stream line later. Probably not the fastest way.

Re: [Tutor] Calculate hours

2013-01-23 Thread Mitya Sirenef
On 01/23/2013 06:13 PM, Alan Gauld wrote: On 23/01/13 03:08, Mitya Sirenef wrote: > >> To make the change you need, use list comprehension to make sums of all >> rows, sort it (using list sort method); iterate over it using >> enumerate() and print out "employee N, sum of hours:" > > One proble

Re: [Tutor] Calculate hours

2013-01-23 Thread Dave Angel
On 01/23/2013 06:13 PM, Alan Gauld wrote: On 23/01/13 03:08, Mitya Sirenef wrote: To make the change you need, use list comprehension to make sums of all rows, sort it (using list sort method); iterate over it using enumerate() and print out "employee N, sum of hours:" One problem with that a

Re: [Tutor] Calculate hours

2013-01-23 Thread Alan Gauld
On 23/01/13 03:08, Mitya Sirenef wrote: To make the change you need, use list comprehension to make sums of all rows, sort it (using list sort method); iterate over it using enumerate() and print out "employee N, sum of hours:" One problem with that approach is that the employees are identifie

Re: [Tutor] Calculate hours

2013-01-23 Thread Dave Angel
On 01/22/2013 11:18 PM, anthonym wrote: Thanks Dave I think I would like to keep it simple. How would I get it to repeat and print before deleting? To repeat something, write a loop. So you have a while loop *outside* the one you've written (you'll have to indent your present loop another

Re: [Tutor] Calculate hours

2013-01-22 Thread anthonym
Thanks Dave I think I would like to keep it simple. How would I get it to repeat and print before deleting? On 1/22/13 7:10 PM, "Dave Angel" wrote: >On 01/22/2013 09:52 PM, anthonym wrote: >> Hello All, >> >> I originally wrote this program to calculate and print the employee >>with the >> mos

Re: [Tutor] Calculate hours

2013-01-22 Thread Mitya Sirenef
On 01/22/2013 10:34 PM, Dave Angel wrote: On 01/22/2013 10:08 PM, Mitya Sirenef wrote: >> On 01/22/2013 09:52 PM, anthonym wrote: >>> Hello All, >> > >> > I originally wrote this program to calculate and print the employee >> > with the most hours worked in a week. I would now like to change th

Re: [Tutor] Calculate hours

2013-01-22 Thread Dave Angel
On 01/22/2013 10:08 PM, Mitya Sirenef wrote: On 01/22/2013 09:52 PM, anthonym wrote: Hello All, > > I originally wrote this program to calculate and print the employee > with the most hours worked in a week. I would now like to change this > to calculate and print the hours for all 8 employ

Re: [Tutor] Calculate hours

2013-01-22 Thread Dave Angel
On 01/22/2013 09:52 PM, anthonym wrote: Hello All, I originally wrote this program to calculate and print the employee with the most hours worked in a week. I would now like to change this to calculate and print the hours for all 8 employees in ascending order. The employees are named employee

Re: [Tutor] Calculate hours

2013-01-22 Thread Mitya Sirenef
On 01/22/2013 09:52 PM, anthonym wrote: Hello All, > > I originally wrote this program to calculate and print the employee > with the most hours worked in a week. I would now like to change this > to calculate and print the hours for all 8 employees in ascending > order. > > The employees are na

[Tutor] Calculate hours

2013-01-22 Thread anthonym
Hello All, I originally wrote this program to calculate and print the employee with the most hours worked in a week. I would now like to change this to calculate and print the hours for all 8 employees in ascending order. The employees are named employee 0 - 8 Any ideas? Thanks, Tony Code bel