1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GarryVolchara [31]
4 years ago
9

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.
Computers and Technology
1 answer:
Zigmanuir [339]4 years ago
7 0

Answer:

 The solution code is written in Python 3:

  1. calories = int(input("Enter number of calories: "))
  2. fats = int(input("Enter number of fat in grams: "))
  3. if(calories > 0 and fats > 0):
  4.    cf = fats * 9
  5.    if(cf < calories):
  6.        percent = cf / calories  
  7.        if(percent < 0.3):
  8.            print("Food is low in fat")
  9.    else:
  10.        print("Error input. Calories from fat cannot more than total calories")
  11. else:
  12.    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)

You might be interested in
For the past five days, the Howard family has traveled these miles: 389;126;419;93; and 394. Find the range and how. Show all yo
Fofino [41]
The answer is 326.

Range is found by subtracting the smallest number in the data set from the largest number.

Highest number: 419
Lowest number: 93

419-93
=326

(Next time make sure to post this under the Mathematics section.)
5 0
3 years ago
Which network type allows a vnic to access a network directly using the host machine's nic?
siniylev [52]
The answer is <span>​Bridge mode.  It is the </span>network type that allows a vnic to access a network directly using the host machine's nic.  <span>In Wi-Fi networking, </span>bridge mode<span> allows two or more wireless access points to communicate and join their respective local networks. </span>
3 0
3 years ago
Given a link with a maximum transmission rate of 28.1 Mbps. Only two computers, X and Y, wish to transmit starting at time t = 0
Sophie [7]

Answer:

0.36

Explanation:

Each Packet Size = 1024 bytes (1000 bytes + 24 bytes)

X gets the transmission first.

Number of packets X has to send = 10,000,000 / 1,000 = 10,000 packets.

Number of packets Y has to send = 14,000 / 1,000 = 14 packets.

Time for one packet to transmit:

28,100,000 bytes in 1 sec

1,024 bytes in = (1/28,100,000) * 1,024 = 0.00003644 secs.

Time taken for X to send = 10,000 * 0.00003644 = 0.3644 secs

Time taken for Y to send = 14 * 0.00003644 = 0.00051016 secs

Time at which File x would finish transmitting = 0.3644 + 0.00051016 = 0.36

Hope this helps!

4 0
3 years ago
This type of technology typically does NOT come with a keyboard or mouse for input.
anyanavicka [17]
The answer is C) tablet. You use the touch screen keyboard for that.
4 0
3 years ago
Read 2 more answers
The East Coast sales division of a company generates 62 percent of total sales. Based on that percentage, write a Python program
Gennadij [26K]

Answer:

def prediction(sales):

print(0.62 * sales)

prediction(4600000)

Explanation:

Code written in python :

We could write it out has a function :

The code is written has a function ;

'def' starts the function which is named prediction. The function takes in a single argument which is the amount of sales made. Since the percentage of sales generated is a constant pegged at 62%. The expression print( 0.62 * sales) outputs the amount generated by east coast. The function call; prediction(4600000) prints the amount generated if a sales of $4600000 is made.

8 0
3 years ago
Other questions:
  • 2. To learn the proper way to set up a table of contents, editors can use a A. style manual. B. dictionary. C. grammar checker.
    15·1 answer
  • why is it when i go to social it shows a post from February it's like i am not with the ppl posting rn
    15·1 answer
  • Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change
    5·1 answer
  • In python:
    8·1 answer
  • A computer's fqdn is pc42042.east.contoso.corp. which option in the advanced tcp/ip settings dialog box must be enabled to allow
    14·1 answer
  • ¿Que es lo que hace tan especial a la tarjeta de video NVIDIA 1080Tt?
    15·1 answer
  • a document contains a list of items that appear in no particular order. what is the best way to format the list
    5·1 answer
  • Which of the following networks had these two goals: a) allowing scientists to work together on scientific projects; and, b) fun
    8·2 answers
  • Given a list of twenty number count the numbers among the list
    7·1 answer
  • One of the most notable impacts of IT on business is improved
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!