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
lakkis [162]
3 years ago
8

Write a program called nearest_multiple.py that asks the user to input a number (here I will call it num) and a strictly positiv

e integer (here I will call it mult) and prints as output the closest integer to num that is a multiple of mult
Computers and Technology
1 answer:
kozerog [31]3 years ago
8 0

Answer:

The program is as follows:

num = float(input("Enter a decimal (float): "))

mult = int(input("Enter a positive whole (int): "))

small = (num // mult) * mult

big = small + mult

print(num,"rounded to the nearest multiple of ",mult,"is",end=" ")

print(big if num - small > big - num else small)

Explanation:

This gets input for num

num = float(input("Enter a decimal (float): "))

This gets input for mult

mult = int(input("Enter a positive whole (int): "))

This calculates the smaller multiple

small = (num // mult) * mult

This calculates the larger multiple

big = small + mult

This prints the output header

print(num,"rounded to the nearest multiple of ",mult,"is",end=" ")

This prints small if small is closer to num, else it prints big

print(big if num - small > big - num else small)

You might be interested in
What kind of Encryption is this:
VMariaS [17]

The Encryption of a website

4 0
3 years ago
How to revive a computer if it functions in an unexpected manner?
julsineya [31]
This would depend on the issue the computer is having. 

In many cases though a simple reboot does the trick. 

If your computer is slow and glitches, try cleaning it for viruses and also clean the fans. If they are dusty the computer can overheat and that can cause it to slow while its working harder to cool down.

In other cases you may not be running the proper software compatible with your device, or programs may be outdated. Check online with the company that manufactured your computer to see if you need to install updates or change certain software. 

3 0
3 years ago
What kind of table is a pasted Word table that can be edited with Word from within PowerPoint without changing the data in your
igomit [66]

D. Integrated

Or

A. Embedded

7 0
3 years ago
Read 2 more answers
An example of financial irresponsibility
Nady [450]

An example of financial irresponsibility is driving without car insurance. The other options are examples of financial responsibility.

3 0
3 years ago
True or False. A modern programming EXE provides a text editor, a file manager, a compiler, a linker and loader, and tools for d
Flauer [41]

Answer:

True

Explanation:

Mordern programming environments provide essential tools needed to build, test, debug, etc. examples are VSCode, Atom, Sublime text, etc.

7 0
3 years ago
Other questions:
  • Im trying to learn c# for unity does anyone know any good sources
    10·1 answer
  • A simple operating system supports only a single directory but allows it to have arbitrarily many files with arbitrarily long fi
    13·1 answer
  • What is software that helps a computer operate efficiently and keeps track of data on a computer?
    14·1 answer
  • How do you determine latitude using an astrolabe?
    11·1 answer
  • Celeste is writing a paper. However, two pages in, her computer shuts down unexpectedly. She never saved her paper, and all her
    12·2 answers
  • Small data files that are deposited on a user's hard disk when they visit a website are called _______.
    6·2 answers
  • Which of the following is an example of an output device
    13·1 answer
  • What is the value of the variable named result after the following code executes?
    10·1 answer
  • Marcus creates a HTML webpage on his favourite game, football. On clicking the word “football” another website containing the in
    11·1 answer
  • Name the first mechanical computer​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!