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
Maru [420]
2 years ago
13

Why would a programmer use a “public” variable for something like speed? Provide at least two other examples of variables a deve

loper would likely make “public.”
Computers and Technology
1 answer:
agasfer [191]2 years ago
7 0

It is useful for things that you don't need to redefine, and you may need to use to compute different things (such that you have different modules/functions to compute each one of these things).

<h3><u>What is a public variable?</u></h3>

A public variable is a variable that any function, sub procedure, or module can access without restriction.

Thus, if you want to define a variable only once and be able to call it from different functions or modules when you need it, you would want to make it a public variable.

An example with speed is:

You can make a simple code that for an initial speed computes the position vs time graph.

But you may want to expand that program, let's say that you make a module that also allows you to find the momentum or something like that (where you also need to use the speed).

Then defining the speed as public, is useful, as you can only call it with the module or function that you use to find the momentum.

Another example, maybe more complete.

Assume that you work with radiation physics. You define a mean energy of radiation (this would be the energy of the x-rays for example).

Now if you define that variable as public, you could use it for a lot of modules to compute a lot of different things, like fluency, kermas, etc.

Things that are really complex to compute and you may have the codes for each one in different modules/functions.

So it is really useful when you already had several codes that work with the same variable.

If you want to learn more about variables, you can read:

brainly.com/question/15683939

You might be interested in
An IT department receives a shipment of 20 new computers, and Alice has been assigned the task of preparing them for deployment
qaws [65]

Answer:

Asset tracking

Explanation:

Asset tracking refers to the method of tracking physical assets, either by scanning barcode labels attached to the assets or by using tags using GPS, BLE, LoRa, or RFID which broadcast their location. These technologies can also be used for indoor tracking of persons wearing a tag.

7 0
3 years ago
Which statement is false? Select one: a. Function printf does not care how large the array it is printing is. b. Function scanf
dusya [7]

Answer:

Option A

Explanation:

Because each function has specific amount of space allocated by default on the stack, so it cares about the length of the array being printed by it. By default the space is up to 100 kb but this size can be increased by setting it manually.

Option B is correct answer because scanf takes input from user until first space is hit.

6 0
3 years ago
Gimme Shelter Roofers maintains a file of past customers, including a customer number, name, address, date of job, and price of
gulaghasi [49]

Answer:

Hence the complete implementation of python code that reads two files and merges them together.

def merge_file(past_file_path,proposed_file_path, merged_file_path):

   past_file_contents=load_file(past_file_path)

   proposed_file_contents=load_file(proposed_file_path)

   proposed_customer_name = []

   for row in proposed_file_contents:

       proposed_customer_name.append(row[1])

   with open(merged_file_path,'w') as outputf:

       outputf.write("Customer Number, Customer Name, Address\r\n")

       for row in proposed_file_contents:

           line = str(row[0]) +", " + str(row[1]) + ", " + str(row[2]) +"\r\n"

           outputf.write(line)

       for row in past_file_contents:

           if row[1] in proposed_customer_name:

               continue

           else:

               line = str(row[0]) + ", " + str(row[1]) + ", " + str(row[2]) + "\r\n"

               outputf.write(line)

       print("Files merged successfully!")

# reads the file and returns the content as 2D lists

def load_file(path):

   file_contents = []

   with open(path, 'r') as pastf:

       for line in pastf:

           cells = line.split(",")

           row = []

           for cell in cells:

               if(cell.lower().strip()=="customer number"):

                   break

               else:

                   row.append(cell.strip())

           if  len(row)>0:

               file_contents.append(row)

   return file_contents

past_file_path="F:\\Past Customer.txt"

proposed_file_path="F:\\Proposed Customer.txt"

merged_file_path="F:\\Merged File.txt"

merge_file(past_file_path,proposed_file_path,merged_file_path)

8 0
2 years ago
A media file refers to what kind of file? A. Clip art
prohojiy [21]

Waveform Audio (.wav) is a common file format. Created by Microsoft and IBM, WAV was one of the first audio file types developed for the PC. WAV files are defined as lossless, meaning that files are large and complete; nothing has been lost.

your answer will be

<h2><em><u>C; image</u></em></h2>
5 0
3 years ago
Read 2 more answers
What is the primary responsibility of the physical layer in data communication?
melamori03 [73]
 It is responsible for transmitting these bits as signals over a wire, optical fiber, wireless, or other <span>medium.</span>
3 0
3 years ago
Other questions:
  • Why has unicode become the standard way of converting binary to text
    7·1 answer
  • What is a custom information field that helps users to find a specific document?
    8·1 answer
  • Smart art can be used to create _____that highlights relationships betweeen two items
    8·2 answers
  • What is the quickest way to change the format of a table?
    8·1 answer
  • What is the most common way for an attacker outside of the system to gain unauthorized access to the target system?
    15·1 answer
  • , 13 dB correspond to a power ratio of ....?
    14·1 answer
  • A digital designer might do computer animations for video games,<br> OA<br> True<br> OB<br> False
    12·2 answers
  • ---------------------- use of the Internet to access programs and data on computers that are not owned and managed by the user o
    9·1 answer
  • A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor.
    14·1 answer
  • Which of the following is a mathematical function defined in the sql standard?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!