Re: [Tutor] Help with return results statement.

2015-10-22 Thread Danny Yoo
An additional suggestion: > = > # Add your functions below! > def average(numbers): > total = sum(numbers) > total = total / len(numbers) > return total Don't re-assign total here. The problem is that conceptually "total" no longer represents the total in the second assignment.

Re: [Tutor] Help with return results statement.

2015-10-22 Thread Vusa Moyo
Thanks Alan. Removed that . = # Add your functions below! def average(numbers): total = sum(numbers) total = total / len(numbers) return total def get_average(student): homework = average(student["homework"]) quizzes = average(student["quizzes"]) tests = average(stude

Re: [Tutor] Help with return results statement.

2015-10-22 Thread Alan Gauld
On 22/10/15 10:03, Vusa Moyo wrote: Hi Guys. Thanks for the responses and assistance. I came right after-all. The last 2 blocks read the following. Glad you are happy but there is still something you could improve: def get_class_average(students): results = [] for a in students:

Re: [Tutor] Help with return results statement.

2015-10-22 Thread Vusa Moyo
Hi Guys. Thanks for the responses and assistance. I came right after-all. The last 2 blocks read the following. def get_class_average(students): results = [] for a in students: b = float(get_average(a)) results.append(b) return average(results) students = [lloyd, al

Re: [Tutor] Help with return results statement.

2015-10-20 Thread Alan Gauld
On 20/10/15 12:29, Vusa Moyo wrote: Hi there. My script is as follows, alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } # Add your function below! def average(numbers): >total = sum(numbers) >

Re: [Tutor] Help with return results statement.

2015-10-20 Thread Steven D'Aprano
Hi Vusa, and welcome. On Tue, Oct 20, 2015 at 01:29:59PM +0200, Vusa Moyo wrote: > Hi there. My script is as follows, [...] > def get_class_average(students): > results = [] > for a in students: > b = int(get_average(a)) > results.append([b]) > return results I'

[Tutor] Help with return results statement.

2015-10-20 Thread Vusa Moyo
Hi there. My script is as follows, lloyd = { "name": "Lloyd", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0] } alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.