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
You have been using the same computer for several years. To extend its service life, you decide to upgrade the processor. You ch
mestny [16]

Answer:

Option B i.e., Update the UEFI firmware.

Explanation:

The user had many periods of using the same machine. He wants to update the processor to increase the existing service period. Later, he tests the paperwork onto the motherboard and buys the best motherboard-supported processor.  

While the user starts the machine, though, that makes a noise constantly, nothing is shown on its monitor and it wouldn't start. So, the first step is he will update firmware from UEFI.

Thus, the other options are not correct according to the scenario.

6 0
4 years ago
How do you represent (decimal) integer 50 in binary
il63 [147K]
Its 110010. i hope this helped
7 0
3 years ago
____ devices are high-performance storage systems that are connected individually to a network to provide storage for the comput
Brut [27]

Answer:lmlmlmlmlmlm

Explanation:

4 0
4 years ago
Write a function getPigLatin(pigStr) that accepts pigStr as a parameter (a sentence as input) and converts each word to "Pig Lat
Vladimir79 [104]

Answer:

userInput = str(input("Enter your sentence here.\n")).upper()

def getPigLatin(userInput):

   splitInput = userInput.split(" ")

   newList = []

   for word in splitInput:

       firstLetter = word[0]

       if len(word) == 1:

           word += 'AY'

           newList.append(word)

       else:

           word = word.strip(word[0])

           word += firstLetter

           word += 'AY'

           newList.append(word)

   print(*newList, sep= " ")

getPigLatin(userInput)

Explanation:

This solution is done in Python

First the user is prompt to enter a statement, the statement converted to string and also capitalize using str and upper() built-in function. The user input is assigned to userInput variable.

The getPigLatin function is defined and it accept a string as parameter. Inside the getPigLatin function, the userInput is splitted and assigned to splitInput variable.

An empty list is also initialized and assigned to newList. Next, we loop through the splitInput. During the loop; we first check if the length of an element is one, then we just add 'AY' to the element and add the element to the newList. Else, if the element length is more than one; we strip the first letter from the word and also re-assign it to word, then the stripped first letter is added to the end of the word. Next, 'AY' is added to the word and the element is add to the newList.

The last line of the getPigLatin function display the entire element of the list using a space seperator.

The last line of the entire solution call the function passing in the userInput as argument.

8 0
4 years ago
When using a direct quotation, which one of the following is not necessary?
ss7ja [257]

Answer:

B

Explanation:

You can't rewrite a source with the writers voice. that makes no sense

6 0
4 years ago
Other questions:
  • Write a program named TypingGrades that allows a user to enter a student’s number of words typed. The output is the letter grade
    9·1 answer
  • which programming paradigm do programmers follow to write code for event driven applications? a. object oriented programming. b.
    9·1 answer
  • How do I attach a file on the computer?
    13·1 answer
  • What is key for evaluating internal controls such as human resources, logistics, information technology, risk, legal, marketing
    11·1 answer
  • Join zoom meet for time pass purpose <br><br>id=547 458 9345<br>pw=sencHURI​
    8·2 answers
  • who will follow me on tiktok and like all my videos? if you do ill give branlist and give u a shoutout and you can enter my big
    15·1 answer
  • Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time.
    6·1 answer
  • Discuss the core technologies and provide examples of where they exist in society. Discuss how the core technologies are part of
    14·1 answer
  • Besides entering a URL to go directly to a website, what else can you enter in a browser address bar to explore the internet?
    9·1 answer
  • How much would you guys pay for a used ps4 with a black ops 3 disc?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!