# Percentage of passing students Module 5.2 15

The question is to find the percentage of student who passed, after almost one hour going back and forth with this, I cannot foresee the solution arriving anytime soon… can someone please explain?

Editor
total_students = int(input(“How many students are in the class?”))
passing_students = int(input(“How many students passed this test?”))

def find_percentage():
percentage = passing_students / total_students

percentage = int(find_percentage() * 100)
print("The percentage of students who passed is " + str(percentage) + “%”)

Shell
How many students are in the class?36
How many students passed this test?9
Traceback (most recent call last):
File “main.py”, line 7, in
percentage = int(find_percentage() * 100)
TypeError: unsupported operand type(s) for *: ‘NoneType’ and ‘int’

found it… just took longer to look at it

I am having this same error. I also wrote this same code, however, now i have messed with it.

Do I have to list arguments for the function find_percentage() in the initial parenthesis? Or do the arguments get put in the print line? Basically, I don’t understand user defined functions.

def find_percentage(x, y):
return (x/y)

percentage = int(find_percentage() * 100)
print("The percentage of students who passed is " + str(percentage) + “%”, find_percentage(passing_students, total_students))

I have also tried this, and get the same error:

def find_percentage(passing_students, total_students):
return (passing_students/total_students)

percentage = int(find_percentage() * 100)
print("The percentage of students who passed is " + str(percentage) + “%”)

Ah! also fixed mine. I forgot a return statement. LMK if you get stuck and want help!