Do you know the math-- what you divide by what to get the percentage? ie, if there are 10 total students, and 7 pass, then there is a .70 percent passing number. So. . . what do you divide by what to get that kind of figure?
Well, you need to set a variable for the quotient between those two numbers-- and I am guessing, since you want the function to tell you the percentage, then that percentage value is what you want to “return”-- correct?
A clearer way to code that might be to set the results of your equation as a variable, ie “percentage = (passing students/total students) * 100”, and then to return the variable. Another issue is that, on the line that you define your function, you want to pass in the variables, not to set up your equation. That should be for a following line.
Hello all,
I have been doing the same as the above and it is not working for me. I have used parentheses and quotations and I just do not have the correct syntax. Can you please clarify? Thanks
Here are some samples of my mistakes:
percentage = passing_students/total_students * 100
percentage = (passing_students/total_students) * 100
“percentage = passing_students/total_students * 100”
percentage = (“passing_students/total_students * 100”)
I concur that the second line of syntax should not cause a problem unless there is some other problem with your function header or definition. Can you share a little more about the problem you’re having?
I don’t know if I did the screenshot right, but there it is. I am just filling in the box. It only says wrong. I typed the exact thing that is in my code that works.
So the wording in the question is tricky. They are not asking to calculate the percentage in the return statement. It is asking what variable divided by another variable could be used in the function body to HELP you determine the percentage?