Student becomes the teacher


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/2?curriculum_id=4f89dab3d788890003000096

<In what way does your code behave incorrectly? Include ALL error messages.>
the last line is shown as “incorrect syntax”

<What do you expect to happen instead?>

```python

Add your function below!

def average(numbers):
total = 0
total= sum(numbers)
print total
total = float(total)
print total
total = total / len(numbers)
print total
return total

def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”]
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

<do not remove the three backticks above>

#2

the last line of the code whenever i run it says that there is a syntax error there.


#3

File “python”, line 35
return (0.1 * homework) + (0.3 * quizzes) + (0.6 * tests)
^
SyntaxError: invalid syntax


#4

Make sure your return statement lines up with all your other lines of code underneath your def get_average(student)


#5

i did that already, it just all went to the end when i copied and pasted it here.


#6

I came across this when I couldnt figure out what I was doing wrong for “5. Its ok to be average” so thanks for clearing something up for me.

The next part is “6. Just weight and see” and I believe this is the part you are enquiring about here.

If you look at the illustration, they use apples and bananas where as we are using “student” along with “homework” and “quizzes” and “tests”.

You will need to change that to work for us and add another line in for “tests” and change the weights too.

I am going to assume the syntax error is that it does not recognise “return 0.1 * homework + 0.3 * quizzes + 0.6 * tests” those variables.

The return statement I used is:
“return 0.1 * average(student[“homework”]) + 0.3 * average(student[“quizzes”]) + 0.6 * average(student[“tests”])”

and it accepted it.

Hope I made this clear enough, you probably figured it out already anyway.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.