answer.
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]
1 year 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]1 year 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
The ________ method is based on simple arithmetic. The process involves dividing the bits of a frame into equal segments, adding
liq [111]

Any answer choices?            


6 0
2 years ago
Given an n-element array X, algorithm D calls algorithm E on each element X[i]. Algorithm E runs in O(i) time when it is called
krek1111 [17]

Answer:

O(n^2)

Explanation:

The number of elements in the array X is proportional to the algorithm E runs time:

For one element (i=1) -> O(1)

For two elements (i=2) -> O(2)

.

.

.

For n elements (i=n) -> O(n)

If the array has n elements the algorithm D will call the algorithm E n times, so we have a maximum time of n times n, therefore the worst-case running time of D is O(n^2)  

5 0
2 years ago
Which of the following commands uses correct syntax for matching the patterns bunk or bank at the end of a line of text?
Alika [10]

Answer:

a. grep 'b[au]nk$' myLine

Explanation:

grep is a command used for searching a specified pattern in a given text.

Our goal is to match the character sequence - bank or bunk at the end of line in a  given line referenced by myLine.

The regular expression for the specified match criterion is:

b[au]nk$

The second character can be either a or u.

$ indicates match at end of line.

So the overall grep command is :

grep 'b[au]nk$' myLine

8 0
1 year ago
Frank works for an organization that wishes to install a software program on a single server with multiple users connected. Whic
Helen [10]
The best answer to this question should be (A) Cloud Computing.

In general, cloud computing is the term used for the delivery of hosted services over the internet. We can also simply put cloud computing as the delivery of computing services like storage, servers, databases, software and more over the internet.




7 0
1 year ago
An automobile battery, when connected to a car radio, provides 12.5 V to the radio. When connected to a set of headlights, it pr
ladessa [460]
Base on the question, and in my further computation, the possible answers would be the following and I hope you are satisfied with my answer and feel free to ask for more.

- If you want to determine the Thevenin equivalent voltage and resistance without overloading the battery, then apply some known resistance 

<span><span>RL</span><span>RL</span></span> and measure the output voltage as <span><span>VL</span><span>VL</span></span>. Measure the voltage without a load as <span><span>V<span>OC</span></span><span>V<span>OC</span></span></span>. The voltage divider equation tells us that

<span><span><span>VL</span>=<span>V<span>OC</span></span><span><span>RL</span><span><span>R<span>TH</span></span>×<span>RL</span></span></span></span><span><span>VL</span>=<span>V<span>OC</span></span><span><span>RL</span><span><span>R<span>TH</span></span>×<span>RL</span></span></span></span></span>

Solve for <span><span>R<span>TH</span></span><span>R<span>TH</span></span></span>, and you know that <span><span><span>V<span>TH</span></span>=<span>V<span>OC</span></span></span><span><span>V<span>TH</span></span>=<span>V<span>OC</span></span></span></span>.

6 0
2 years ago
Other questions:
  • Open this link after reading about Ana's situation. Complete each sentence using the drop-downs. Ana would need a minimum of ato
    5·2 answers
  • Kleene star of {1} generates {1, 11, 111, 1111, 11111……}.<br> True<br> False
    12·1 answer
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • Which of the following is not true about VOIP?
    9·1 answer
  • Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompt
    9·1 answer
  • 7. Which of these statements is true? Agile is a programming language MySQL is a database HTML stands for "Hypertext Markup Link
    15·1 answer
  • If a class has member variables that are pointers, you must ensure that you implement ____.
    6·1 answer
  • Why is it important for element IDs to have meaningful names?
    11·1 answer
  • Import simplegui
    10·1 answer
  • A large offshore oil platform needs to transmit signals between different devices on the platform with high reliability and low
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!