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
Lana71 [14]
3 years ago
8

Describe the scope of the variables in this code.

Computers and Technology
2 answers:
Solnce55 [7]3 years ago
7 0

Answer:

The scope of petName is local to the class pet.

The scope of color is accessible by all parts of the program.

Explanation:

The variable petName is local to the class, because the variable was created in a function whose name begins with two underscores.

The variable color, while created in the petCarrier class, is accessible to the entire function. It was not created in a function whose name begins with an underscore.

Correct answer edge 2020

tensa zangetsu [6.8K]3 years ago
6 0

Answer:

Scope of petName is only limited to class pet (pet class) and scope of color is accessible to the entire program.

Explanation:

petName is restricted by the contructor with an underscore: def __init__(self,strSpecies,strName):, meaning it cannot be manipulated outside that class and color does not have that.

You might be interested in
The main difference between a lan, a man, and a wan is _____. the ability to connect to the internet the geographic area they co
garri49 [273]
The geographic area they cover and the use of an ISP.
6 0
4 years ago
Write a C program to insert and delete values from a stack(to perform pop and push operations) using an array data structure
Bumek [7]
<h2>Answer:</h2>

#include<stdio.h>

// Method to insert a value into a stack

void push(char value, char myStack[], int *top, int sizeOfStack){

   if(*top == -1){

       myStack[sizeOfStack - 1] = value;

       *top = sizeOfStack - 1;

   }

   else if(*top == 0){

       printf("Stack is full. \n");

   }

   else{

       myStack[(*top) - 1] = value;

       (*top)--;

   }

}

//Method to remove a value from a stack

void pop(char myStack[], int *top, int sizeOfStack){

   if(*top == -1){

       printf("Stack is empty. \n");

   }

   else{

       printf("Value removed: %c \n", myStack[(*top)]);

       // Now if the value removed was the last value in the stack

       // you should set top to -1.  

       // This would show that the stack is now empty

       if((*top) == sizeOfStack - 1){

           (*top) = -1;

       }

       else{

           (*top)++;

       }

   }

}

//Method to test the pop and push methods

int main() {

 //variable to hold the size of stack

 int sizeOfStack = 6;

 //create the stack

 char myStack[sizeOfStack];

 

 //set the top to -1

 //this is to show that the stack is initially empty

 int top = -1;

 //insert a value tot the stack

 push('x', myStack, &top, sizeOfStack);

 //print the value on the top

 printf("Value on top of stack: %c\n", myStack[top]);

 //insert another value to the stack

 push('y',myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //insert another value to the stack

 push('z',myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //remove the last inserted value

 pop(myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //remove another value

 pop(myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 return 0;

}

<h2>Sample Output:</h2>

Value on top of stack: x

Value on top of stack: y

Value on top of stack: z

Value removed: z  

Value on top of stack: y

Value removed: y  

Value on top of stack: x

<h2>Explanation:</h2>

The code above has been written in c and it contains comments explaining important parts of the code. Please go through the comments.

It also contains a sample output resulting from the run of the program.

4 0
3 years ago
Difference between entropy and enthalpy is
olchik [2.2K]

Answer:

Explanation:

Enthalpy is the measure of total heat present in the thermodynamic system where the pressure is constant. Entropy is the measure of disorder in a thermodynamic system.

3 0
3 years ago
given:an int variable k,an int array currentMembers that has been declared and initialized,an int variable memberID that has bee
Oksi-84 [34.3K]

Answer:

// The code segment is written in C++ programming language

// The code segment goes as follows

for (k = 0; k < nMembers; k++)

{

//check if memberID can be found in currentMembers

if (currentMembers[k] == memberID){

// If yes,

// assigns true to isAMember

isAMember = true;

k = nMembers;

}

else{

isAMember = false;

// If no

// assigns false to isAMember

}

}

// End of segment:

The following assumption were made in the code segment above.

There exists

1. An already declared and initialised int array currentMembers.

2. An already initialised int variable memberID

Line 3 initiates a loop to scan through the array

Line 6 checks for the condition below

If current element of array equals memberID then

It assigns true to isAMember and nMembers to k

Else

It assigns false to isAMember

7 0
3 years ago
a 0.600 kg dynamics trolley has 1.5 kg load added. It is launched with a force of 10.n what is the acceleration
Anastaziya [24]

Answer:

acceleration = 4.76 m/s²

Explanation:

Given that"

the mass of the dynamic trolley = 0.6 kg

the mass of the load  = 1.5 kg

total mass = (0.6 + 1.5) kg = 2.1 kg

the force = 10 N

Thus;

using the formula of force which is;

Force = mass × acceleration

10 = 2.1  × acceleration

acceleration = 10/2.1

acceleration = 4.76 m/s²

7 0
3 years ago
Other questions:
  • Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as in
    5·2 answers
  • Which of the following statements is false?a.Unethical behavior is always illegal.b.Ethical decisions are usually influenced by
    12·1 answer
  • The growing network of physical objects that will have sensors connected to the Internet is referred to as the ________.
    13·1 answer
  • How can you prevent your VMs receiving DHCP server messages from unauthorized virtual machine pretending to be DHCP servers?
    13·1 answer
  • Alex builds a 1 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
    6·1 answer
  • 1. PGP encryption can be performed from the command line as well. What is the PGP command line syntax to encrypt the my-message.
    7·1 answer
  • Write a program that will read the payroll file. It should output the name and paycheck amount. Also output the total pay of all
    13·1 answer
  • Which IP QoS mechanism involves prioritizing traffic? Group of answer choices IntServ RSVP COPS DiffServ None of the above
    14·1 answer
  • The most common types of utility programs fall into these categories.
    7·1 answer
  • Variables that can take only 2 variables are referred to as which one of the following?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!