Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37912
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-01-29 19:26 -0800 |
| Message-ID | <72be91aa-b9fc-4225-bd54-0ae3459acea3@googlegroups.com> (permalink) |
| Subject | struggling with these problems |
| From | su29090 <129km09@gmail.com> |
1.Given that worst_offenders has been defined as a list with at least 6 elements, write a statement that defines lesser_offenders to be a new list that contains all the elements from index 5 of worst_offenders and beyond. Do not modify worst_offenders . I tried this but it didn't work: lesser_offenders = worst_offenders[5:6] 2.Given a variable temps that refers to a list, all of whose elements refer to values of type float , representing temperature data, compute the average temperature and assign it to a variable named avg_temp . Besides temps and avg_temp , you may use two other variables -- k and total . I'm not sure about this one but this is what I have: for k in range(len(temps)): total += temps[k] avg_temp = total / len(temps) 3.Associate the sum of the non-negative values in the list numbers with the variable sum . is it this: for numbers in sum: if sum +=? I'm confused at #3 the most i'm not doing it in python 3.2.3 it's called Myprogramminglab.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
struggling with these problems su29090 <129km09@gmail.com> - 2013-01-29 19:26 -0800
Re: struggling with these problems MRAB <python@mrabarnett.plus.com> - 2013-01-30 03:59 +0000
Re: struggling with these problems Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-30 04:43 +0000
csiph-web