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
To assign a conditional value, use the ____ function.
zubka84 [21]
<span>To assign a conditional value, use the IFF function.  It is an abbreviation for  Immediate If.  It is a function </span>on spreadsheets that returns the second or third parameter based on the evaluation of the first parameter.  <span>You use </span>IIf<span> to determine if another expression is true or false. If the expression is true, 
</span>IIf<span> returns one value; if it is false, </span>IIf<span> returns another.</span>
3 0
3 years ago
In terms of computer networking. what is PING?
Andrew [12]
Ping means how much of a delay there is in your connection. The lower the ping, the smaller the delay. This plays an important role in online gaming. If your ping is 350, then your delay is 350ths of a second.

3 0
3 years ago
You are working as a Software Programmer for one of the big retail company. You need to implement the program that can store at
Aleks [24]

Answer:

The C++ code is given below with appropriate comments. Random names of customer information are chosen as samples

Explanation:

#include <iostream>

using namespace std;

int main()

{

// Initialize String Arrays for customerName,customerAddress1,city,state,zip for 15 customers

string customerName[15] = {"Liam","Noah","William","James","Logan","Benj","Mason","Elijah","John","Patty","Cheryl","Nick","Brian","Steve","mark"};

string customerAddress1[15] = {"Liam - Address1","Noah - Address2","William - Address3","James - Address4","Logan - Address5","Benjamin - Address6","Mason - Address7","Elijah - Address8","John - Address9","Patty - Address10","Cheryl - Address11","Nick - Address12","Brian - Address13","Steve - Address14","mark - Address15"};

string city[15] = {"Sitka","Juneau","Wrangell","Anchorage","Jacksonville","Anaconda","Oklahoma City","Fort Worth","Dallas","Sitka","Juneau","Wrangell","Anchorage","Jacksonville","Anaconda"};

string state[15] = {"Alaska","Alaska","Alaska","Alaska","Florida","Montana","Montana","Oklahoma","Texas","Arizona","Tennessee","California","Virginia","Indiana","Virginia"};

int zip[15] = {30041,36602,75062,78952,12071,55874,11236,44512,55262,99874,11020,55820,11304,11587,11047};

// Print Zips for the customers

cout <<"Customer Names"<<"\t"<< "Zip Code"<< "\n";

for (int i = 0; i < 15; i++)

cout <<customerName[i]<<"\t\t\t"<< zip[i] << "\n";

}

5 0
3 years ago
When following proper netiquetter rules you should follow all of the following rules except _____. Question 11 options: Don't us
vfiekz [6]

The answer is C. Use sarcasm and jokes in your e-mails to make the reader laugh


Sarcasm and jokes can be difficult to understand through text-based communication like e-mails, so it is best to avoid them altogether, especially in formal settings.

6 0
3 years ago
Read 2 more answers
Guided transmission media employ an antenna for transmitting through air or vacuum.
olganol [36]

Answer: False

Explanation:

Unguided medium employs an antenna for transmitting through air or vacuum.

For guided mediums the transmission is in the form of twisted copper wires, shielded twisted copper wire and optical fibres. They henceforth do not depend upon antennas for transmission through air using antennas.

5 0
4 years ago
Other questions:
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • PLEASE HELPPPPPPP
    15·1 answer
  • What were the technological innovations that allowed for the rapid expansion of the railroads?
    6·1 answer
  • What is an icon?
    6·1 answer
  • What the heck is a motherboard and why is my computer not working when i take it out
    14·1 answer
  • A copy of the copyrighted work must be exactly the same as the original to infringe a copyright.
    9·1 answer
  • MICR is an input or output devices
    5·1 answer
  • The program that is BEST suited
    12·1 answer
  • Write the definition of a public class Simple. The class has no constructors, methods or instance variables.
    6·2 answers
  • Write an if-else statement for the following: If user_tickets is less than 5, assign num_tickets with 1. Else, assign num_ticket
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!