In 5.2 why did they use a definition in the program like below,

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 = int(find_percentage() * 100)

print("The percentage of students who passed is " + str(percentage) + “%”)

I did it without like this and it seems to work just as well.

total_students = int(input(“How many students are in the class?”))

passing_students = int(input(“How many students passed this test?”))

percentage = passing_students/total_students * 100

print("The percentage of students who passed is " + str(percentage) + “%”)

Am I missing something?