Write a program that asks for the number of calories and fat grams in a food. The program should display the percentage of calor
ies that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating that the food is low in fat. One gram of fat has 9 calories, so Calories from fat = fat grams * 9 The percentage of calories from fat can be calculated as Calories from fat total calories Input Validation: Make sure the number of calories and fat grams are not less than 0. Also, the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indicating that either the calories or fat grams were incorrectly entered.
calories = int(input("Enter number of calories: "))
fats = int(input("Enter number of fat in grams: "))
if(calories > 0 and fats > 0):
cf = fats * 9
if(cf < calories):
percent = cf / calories
if(percent < 0.3):
print("Food is low in fat")
else:
print("Error input. Calories from fat cannot more than total calories")
else:
print("Error input. Calories and fats must be more than 0")
Explanation:
Firstly, use input function to ask user to enter total number of calories and fat in grams (Line 1-2)
Next we do the first input validation to check if the calories and fats are more than 0 (Line 4). If so apply formula to calculate calories from fats. If not, print error input message (Line 5, 13)
Then we proceed to next input validation to check if calories from fact more than total calories. If so, proceed to calculate percentage of calories from fats and if it is lower than 30%, display the appropriate message (Line 6 - 9). If fail the second input validation, the program will display another error input message again (Line 11)
AKA Satellite Dishes That Communicate Just Like Direct Tv dish It is focused by a bowl-shaped parabolic dish onto a device in the center called a "feed horn", which channels the signal to a "low-noise block down converter" (LNB) which filters out unwanted interference, and sometimes converts it to yet another frequency before amplifying it and sending it to the satellite receiver
Practice! And a good keyboard I recommend mechanical key boards But the best way to improving your WPM is definitely practice one way you can practice is playing typeracer it’s pretty fun way