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
emmainna [20.7K]
3 years ago
11

Write a program that declares and initializes a variable representing the weight in milligrams from the keyboard. The program di

splays the equivalent weight in kilograms, grams, and milligrams. For example, 1050042 milligrams are equivalent to 1 kilogram, 50 grams, and 42 milligrams.
Computers and Technology
1 answer:
Burka [1]3 years ago
3 0

Answer:

weight = int(input("Enter weight in milligrams: "))

kilograms = int(weight / 1000000)

grams = int((weight - (kilograms * 1000000)) / 1000)

milligrams = weight - ((kilograms * 1000000) + (grams * 1000))

print("{} milligrams are equivalent to {} kilogram(s), {} gram(s), and {} milligram(s)".format(weight, kilograms, grams, milligrams))

Explanation:

*The code is in Python.

Ask the user to enter the weight and set it to the variable weight

Calculate the kilograms, divide the weight by 1000000 and cast the result to the int (If the weight is 1050042, kilograms would be 1050042/1000000 = 1)

Calculate the grams, subtract the kilograms from the weight, divide it by 1000 and cast the result to the int (If the weight is 1050042, grams would be int((1050042 - (1 * 1000000)) / 1000) = 50)

Calculate the milligrams, subtract the kilograms and grams from the weight (If the weight is 1050042, milligrams would be 1050042 - ((1 * 1000000) + (50 * 1000)) = 42)

Print the weight, kilograms, grams, and milligrams in the required format

You might be interested in
A 'deny any-any' rule in a firewall ruleset is normally placed: a. Nowhere in the ruleset if it has a default allow policyb. Bel
tia_tia [17]

Answer:

D. . At the bottom of the ruleset

Explanation:

The main purpose of firewalls is to drop all traffic that is not explicitly permitted. As a safeguard to stop uninvited traffic from passing through the firewall, place an any-any-any drop rule (Cleanup Rule) at the bottom of each security zone context

6 0
4 years ago
Michael is stuck due to an electric shock generated at the fridge. What should you do to save michael?.
NISA [10]

Pull him away from the fridge with a non-conducting material and begin cardiopulmonary resuscitation .

<h3>What is meant by electric shock?</h3>

When a human comes into contact with an electrical energy source, they experience an electric shock. A shock is produced when electrical energy passes through a section of the body. Exposure to electrical energy has the potential to cause fatalities or absolutely no injuries.

The tangible and tangible result of an electrical current entering the body is electrical shock. The shock could be anything from a dangerous discharge from a power line to an uncomfortable but safe jolt of static electricity after walking over a thick carpet on a dry day. trauma; related topics.

The complete question is : Michael is stuck due to an electric shock generated at the fridge. What should you do to save Michael?

A. push the fridge away with a non-conducting material and begin cardiopulmonary resuscitation

B. push the fridge away from him and begin cardiopulmonary resuscitation

C. pull him away from the fridge with a non-conducting material and begin cardiopulmonary resuscitation

D .pull him away from the fridge with your hands and begin cardiopulmonary resuscitation

To learn more about electric shock refer to:

brainly.com/question/28361869

#SPJ1

7 0
1 year ago
What are the four main content questions that need to be answered for every project you work on?
7nadin3 [17]

Answer: 1. What are the major deliverables ?

2. How will you get those deliverables before or by the deadline ?

3. Who is on the on the team and what role will they play ?

4. When will the team meet milestones on when will other members on the team play a role in. Contributing to or providing feedback on those deliverables ?

3 0
3 years ago
How do i add an answer on brainly i click to add an answer and it sends me to the home page
cricket20 [7]

Answer:  try to just add as little as possible then add the answser or just reload your browser

Explanation:

7 0
3 years ago
Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the
pantera1 [17]

Answer:

The solution code is written in Python

  1. numList = [10, 20, 30, 40]
  2. for i in range(0, len(numList) - 1):
  3.    numList[i] = numList[i] + numList[i + 1]
  4. print(numList)

Explanation:

Firstly, create a sample number list, numList (Line 1)

Create a for-loop that will traverse through the array element from 0 till the second last of the element (len(numList) - 1) (Line 3)

Set the current element, numList[i], to the sum of the current element, numList[i] and the next element, numList[i+1]

Print the modified numList (Line 6) and we can see the output as follows:

[30, 50, 70, 40]

4 0
3 years ago
Other questions:
  • Consider that an individual threat agent, like a hacker, can be a factor in more than one threat category. If a hacker breaks in
    5·1 answer
  • After reading passage “the incredible machine” why do you think the article has been titled so?
    13·1 answer
  • What is the maximum duration of daily scrum meetings A:15minsB:45minsC10mins:30mins
    7·2 answers
  • The Internet of Things (IoT) is a global information architecture that could contain
    12·1 answer
  • Combinations of spaces and special characters can be used in domain names of uniform resource locators (urls).
    6·2 answers
  • Asymmetric key encryption combined with the information provided by a. certificate authority allows unique identification of the
    8·1 answer
  • What are some excuses for not attending online classes ( for students )​
    13·1 answer
  • In saving a Visual Basic project properly , which of the following: two components part are involved ?
    6·1 answer
  • Several people work with data at Erica’s office. She enters data. One of her coworkers enters new product numbers. Another cowor
    5·1 answer
  • True or False? Voice recognition is the process of determining the meaning of the words spoken by a human.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!