Read the following code used to calculate the percentage of calories from fat in an item:


calories = input("How many calories are in the item? ")

caloriesFat = input("How many calories are from fat? ")

percentFat = caloriesFat / calories


There is an error in the code. What type of function needs to be used?


float() [I think it is this one. Is it right?]

int()

print() [NOT this one!]

str()

Respuesta :

Explanation:

Problem is to cast your input values either in int() or float() this this up to you in which format you want your output,

Example2:

calories = int(input("How many calories are in the item? "))


caloriesFat = int(input("How many calories are from fat? "))


percentFat = int(caloriesFat / calories)

Now output on the screen:

print(percentFat)


Example2:

calories = float(input("How many calories are in the item? "))


caloriesFat = float(input("How many calories are from fat? "))


percentFat = float(caloriesFat / calories)

Now output on the screen:

print(percentFat)

I hope you got the idea Thanks

Answer:

The answer is int ()

Explanation:

Process of elimination. Only int and float are used for calculation (division obvs falls under that). Disregard the other two options. Float is for numerical values with a decimal. Calories are never shown with decimal points. So, it's int()