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
Read the PIC Data sheet Chapter 2.0 and 3.0 2. List at least 3 big differences between the Flash and RAM 3. How many RAM locatio
Alex Ar [27]

Answer: Incomplete question

Explanation: The question attached is incomplete and incoherent, possible solution of this will be difficult to assume. Take adequate time to post complete questions.

Regards.

4 0
3 years ago
In the beginning of a presentation, it is important to:
tangare [24]

I think it is better to ask questions and troduce yourself

4 0
3 years ago
question 2 which data link layer protocol defines the process by which lan devices interface with upper network layer protocols?
erma4kov [3.2K]

The correct answer is MAC (Media Access Control).

<h3>What is MAC?</h3>

The Media Access Control (MAC) protocol is a data link layer protocol that defines the process by which local area network (LAN) devices interface with upper network layer protocols, such as the Internet Protocol (IP).

The MAC protocol is responsible for controlling access to the shared communication medium of the LAN and for providing a reliable link between devices on the LAN. It does this by defining a set of rules and procedures for how devices on the LAN can detect and avoid collisions when transmitting data, as well as for how they can recover from errors that may occur during transmission.

The MAC protocol is typically implemented in hardware, such as in the network interface controller (NIC) of a computer, and is an essential part of the LAN communication process.

To Know More About MAC, Check Out

brainly.com/question/29388563

#SPJ1

6 0
1 year ago
Who would use a CLI? (Command Line Interface)
JulijaS [17]
CLIs are often used by programmers and system administrators, in engineering and scientific environments, and by technically advanced personal computer users.
7 0
3 years ago
What action should you take if you become aware that sensitive compartmented information has been compromised
irina [24]

The sensitive compartmented information can not be compromised and in case found with the incident it must be reported to the security officer.

<h3>What is Sensitive Compartmented Information?</h3>

The sensitive compartmented information is given as the sensitive information to the United States gathered with the source of the intelligence and the analytical process.

The information has been sensitive and was considered not to be compromised. In case the information is found to be compromised, the security officer of the information must be contacted to check into the details.

Learn more about sensitive information, here:

brainly.com/question/25948574

#SPJ1

5 0
1 year ago
Other questions:
  • An effectively distributed resume will get an interview
    12·2 answers
  • What is a way to minimize technical problems with computer
    13·1 answer
  • Which loan type requires you to make loan payments while you’re attending school?
    9·1 answer
  • ______________ is only one of the marketing mix tools that acompany uses to achieve its marketing objectives.
    7·1 answer
  • 11. Print Layout, Full Screen Reading, Web Layout, Outline and Draft are examples of _______. 12. What do you do if the spelling
    5·1 answer
  • What are two major techniques involved in green computing
    14·1 answer
  • Plato Web Tech B Semester Test- I'll mark brainiest for answers to ALL
    9·1 answer
  • Write a program to read from std_info.txt.
    11·1 answer
  • Choose the term that matches the action.
    5·2 answers
  • How to give a brainiest on a question? if you teach me i will give brainiest
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!