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
stepladder [879]
3 years ago
10

"Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that de

activates the alarm, and armed which contains a boolean describing whether or not the alarm is activated. Alarm has a function disarm that changes the value of armed to False if the user gives a parameter containing the string that represents the alarm's code. Call the disarm function on the Alarm object myAlarm and give it the code "93478"."
Computers and Technology
1 answer:
Marrrta [24]3 years ago
7 0

Answer:

Following are the program in the Python programming Language.

#define class

class Alarm:

 #define constructor

 def __init__(self,code,armed = False):

   self.code = code #initialize value

   self.armed = armed #initialize value

 #define function

 def changeCode(self,currentCode,newCode):

   #set if conditional statement

   if currentCode == self.code:

     #initialize value if the condition is true

     self.code = newCode

     #return value

     return newCode

#set object of the class and pass value in constructor  

myAlarm=Alarm("93478")

#call and print the function

myAlarm.changeCode("93478","1234")

print(myAlarm.code)

<u>Output</u>:

1234

Explanation:

Here, we define a class "Alarm" and inside the class.

  • Define a constructor and pass arguments in its parameter "code" ,"armed" and assign a boolean value in the variable "armed" to False.
  • Then, initialize the variables inside it.
  • Define the function name "changeCode()" and pass arguments in its parentheses "currentCode" and "newCode" inside it, we set if condition and check whether the "currentCode" is equal to the code the initialize into code the value of "newCode".

Finally, we set an object of the class and pass value in its parentheses for the constructor and then, we call the function and pass values in its parameter then, we print the code.

You might be interested in
Why do so many people think the revision stage is the hardest
tia_tia [17]

It is because many people want to be perfect just at the start, but there is always room to improvement, but people don't accept that, so they don't want to be better than what they are already, so the don't revise themselves or anything.


6 0
3 years ago
Read 2 more answers
Suppose you can access the caches in the local DNS servers of your department. Can you propose a way to roughly determine the We
lubasha [3.4K]

Answer:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers.

Explanation:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers. The Web server that appears most frequently in the  Domain Name System (DNS) caches is the most popular server. This is because if more users are interested in a Web server, then Domain Name System (DNS) requests for that server are more frequently sent by users. Thus, that Web server will appear in the  Domain Name System (DNS) caches more frequently.  

6 0
3 years ago
What is a list of data organized for easy access?
ozzi

Answer:

An Array

Explanation:

Array and Object is a good use for storing data and accessing it

6 0
2 years ago
Define a function SetTime, with int parameters hoursVal and minutesVal, that returns a struct of type TimeHrMin. The function sh
Lapatulllka [165]

Answer:

#include <stdio.h>

typedef struct TimeHrMin_struct //struct

{

int hours;

int minutes;

} TimeHrMin;

struct TimeHrMin_struct SetTime(int hoursVal,int minutesVal) //SetTime function

{

struct TimeHrMin_struct str;

str.hours=hoursVal; //assigning the values

str.minutes=minutesVal;

return str; //returning the struct

}

int main(void)

{

TimeHrMin studentLateness;

int hours;

int minutes;

scanf("%d %d", &hours, &minutes);

studentLateness = SetTime(hours, minutes); //calling the function

printf("The student is %d hours and %d minutes late.\n", studentLateness.hours, studentLateness.minutes);

return 0;

}

Explanation:

4 0
3 years ago
_ is the use of a collection of computers, often owned by many people or different organizations, to work in a coordinated manne
ddd [48]

Answer:

"Grid computing" is the correct answer for the above question.

Explanation:

  • Grid computing is a process in which many computers are participating to solve a single problem. This type of process is distributed multiple computers to perform a different type of task.
  • If there is large problem and if many computers solve that problem, then that problem is solved easily within a few minutes.
  • This is because many computers are working for that problem.
  • The above question asked about that process in which many computers are working to solve a single problem. This processor is known as "Grid Computing".
8 0
3 years ago
Other questions:
  • Where do scanned documents go in windows 10?
    11·1 answer
  • What is the main storage location of a computer
    13·1 answer
  • According to ________ law, in a sealed chamber, the pressure and temperature of a gas are directly related to each other.
    10·1 answer
  • Which payment type is best if you are trying to stick to a budget?
    6·1 answer
  • I need help!
    14·1 answer
  • What is are motor vehicle emissions?
    8·1 answer
  • Can you install Ubuntu on a hard drive by porting from the folder to the HDD?
    10·1 answer
  • Which of these parts serves as the rear cross structure of a vehicle?
    12·1 answer
  • You compared each letter in the correct word to the letter guessed.
    5·1 answer
  • Write a declaration of a variable named count that can be used to hold numbers like 90000 and -1 and -406.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!