108k views
2 votes
Two variables, num_boys and num_girls, hold the number of boys and girls that have registered for an elementary school. The variable budget holds the number of dollars that have been allocated to the school for the school year. Write code that prints out the per-student budget (dollar spent per student). If a division by zero error takes place, just print out the word "unavailable".

1 Answer

1 vote

Answer:

Using python

num_boys = int(input("Enter number of boys :"))

num_girls = int(input("Enter number of girls :"))

budget = int(input("Enter the number of dollars spent per school year :"))

try:

dollarperstudent = budget/(num_boys+num_girls)

print("Dollar spent per student : "+str(dollarperstudent))#final result

except ZeroDivisionError:

print("unavailable")

User Kim Hyesung
by
8.1k points

No related questions found