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
S_A_V [24]
3 years ago
14

For this lab you will do 2 things:

Computers and Technology
1 answer:
zepelin [54]3 years ago
4 0

Answer:

Here is the Python program:

COOKIES_PER_BAG = 40 #sets constant value for bag of cookies

SERVINGS_PER_BAG = 10 #sets constant value for serving in bag

CALORIES_PER_SERVING = 300 #sets constant value servings per bag

cookies = int(input("How many cookies did you eat? ")) #prompts user to input how many cookies he or she ate

totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG)); #computes total calories consumed by user

print("Total calories consumed:",totalCalories) #displays the computed value of totalCalories consumed

Explanation:

The algorithm is:

  • Start
  • Declare constants COOKIES_PER_BAG, SERVINGS_PER_BAG and CALORIES_PER_SERVING
  • Set COOKIES_PER_BAG to 40
  • Set SERVINGS_PER_BAG to 10
  • Set CALORIES_PER_SERVING to 300
  • Input cookies
  • Calculate totalCalories:                                                                                                                       totalCalories ← cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG))
  • Display totalCalories

I will explain the program with an example:

Lets say user enters 5 as cookies he or she ate so

cookies = 5

Now total calories are computed as:

totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG));  

This becomes:

totalCalories = 5 * (300/40/10)

totalCalories = 5 * (300/4)

totalCalories = 5 * 75

totalCalories = 375

The screenshot of program along with its output is attached.

You might be interested in
THIS IS PYTHON QUESTION
frozen [14]

Answer:

ok

Explanation:yes

4 0
2 years ago
python Write a program that will take a file named Celsius.dat that contains a list of temperatures in Celsius (one per line), a
jekas [21]

with open('celcius.dat', 'r') as fIn, open('fahrenheit.dat', 'w') as fOut:

   for line in fIn:

       fahrenheit = 9.0 / 5.0 * float(line) + 32

       fOut.write("%.1f\n" % fahrenheit)


You can control the number of decimals in the formatting clause in the write statement.

6 0
3 years ago
What will be returned when the following SQL statement is executed?
ycow [4]

Answer:

b) A listing of each driver as well as the number of deliveries that he or she has made

Explanation:

SQL which stands for Structured Query Language. and an SQL statements are used in performing tasks such as to update data on a database, or retrieve data from a database. Some of the popular relational database management systems that use SQL are: Sybase, Oracle, Microsoft SQL Server, Ingres, Access, etc.

3 0
3 years ago
Read 2 more answers
What type of hard drive is in original xbox?
castortr0y [4]
The original Xbox had an 8GB hard disk drive, or HDD.

You basically gave yourself the answer! A hard drive.
4 0
3 years ago
(tco 8) when a file is opened in the append mode, the file pointer is positioned
Artyom0805 [142]
At the end of the file, so that additional data is appended while the existing data stays intact.
6 0
3 years ago
Other questions:
  • Peak download rate for a 4g network is __________. select one:
    12·2 answers
  • How do smart watches affect the business and its position in the global marketplace?
    12·2 answers
  • Describe how computer is in the last 35 years
    6·1 answer
  • What is the role of the federal government in regulating the media and the internet?
    6·2 answers
  • The first step in the information processing cycle is _____, which involves entering data into the computer.
    8·1 answer
  • Consider the following C program: int fun(int *i) { *i += 5; return 4; } 352 Chapter 7 Expressions and Assignment Statements voi
    11·1 answer
  • What is the<br> binary code<br> for<br> "DMS"?
    8·1 answer
  • David is taking a test. To answer a question, he first covers up the answer choices. Next, he tries to answer the question. Then
    15·2 answers
  • ...............is a personal computer that fits on desk.​
    5·2 answers
  • Basics of visual basic
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!