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
postnew [5]
3 years ago
8

1. We want to add a button to the tally counter in Section 9.2 that allows an operator to undo an accidental button click. Provi

de a method def undo(self) that simulates such a button. As an added precaution, make sure an undo doesn't cause the counter to be less than zero. 5 pts a) Your code with comments b) A screenshot of the execution Test Case: Reset 2 clicks Print Value 1 click Print Value 2 undos Print Value 2 undos Print Value
Computers and Technology
1 answer:
serious [3.7K]3 years ago
5 0

Answer:

See explaination

Explanation:

class Counter:

def getValue(self):

return self._value

def undo(self):

if self._value > 0:

self._value = self._value - 1;

def click(self):

self._value= self._value + 1

def reset(self):

self._value= 0

tally= Counter()

tally.reset()

tally.click()

tally.click()

result = tally.getValue()

print("Value:", result)

tally.click()

result = tally.getValue()

print("Value:", result)

tally.undo()

tally.undo()

result = tally.getValue()

print("Value:", result)

tally.undo()

tally.undo()

result = tally.getValue()

print("Value:", result)

You might be interested in
Given two integers low and high representing a range, return the sum of the integers in that range. For example, if low is 12 an
Vaselesa [24]

       System.out.println(sumRange(12, 18)); // prints 105

       System.out.println(sumRange(18, 12)); // prints 0

       System.out.println(sumRange(18, 18)); // prints 18

   }

   public static int sumRange(int low, int high)

   {

       int sum = 0;

       for (int val = low; val <= high; val++){

           sum += val;

       }

       return sum;

   }

}

8 0
3 years ago
Unlike clip art, you cannot resize a photograph using the mouse. <br> a. True<br> b. False
masya89 [10]
<span>b. false; unlike clip art, you cannot resize a photograph

</span>
7 0
3 years ago
Pros and cons of using the internet
MAVERICK [17]
It is easy to find information, but it is not always right.
7 0
3 years ago
Read 2 more answers
If byte stuffing is used to transmit Data, what is the byte sequence of the frame (including framing characters)? Format answer
Lerok [7]

Answer:

Correct Answers: 01h 79h 1Bh 78h 78h 1Bh 7Ah 04

Explanation:

Solution is attached below

4 0
3 years ago
You have been asked to improve on the web page you created for NewYou Personal Training. You will use the file you created for T
34kurt

Answer:

See explaination

Explanation:

<!DOCTYPE html>

<html lang="en" dir="ltr">

<head>

<meta charset="ut f-8">

<title>Tutorial Project 1</title>

<style type="text/css">

p{

font-family: Georgia, serif;

}

</style>

<link rel="stylesheet" type="text/css" href="project3style.css">

</head>

<body>

<img src="images/logo.jp g" alt="New You Personal Training Banner">

<h2>Welcome to NewYou Personal Training</h2>

<h3>Our services include:</h3>

<h3>Call today to speak to one of our fitness specialists</h3>

<section>

<p style="color: darkorange;font-weight: 900;">

<ul>

<li> Fitness evaluations with optimal 360&#176; Computerized Body Profile.</li>

<li> Complete individualized training plan with free workout schedule calendar.</li>

<li> Private workout guidance provided daily to help you meet your personal goals.</li>

<li> Complimentary diet and nutrition counseling. </li>

<li> Email and text messaging reminders to help keep you on track.</li>

<li> Workout group sessions for those who prefer to exercise in a group setting.</li>

</ul>

</p>

<p>

<b><i>All fitness and nutrition services can be provided at our brand new facility or in the privacy of your own home or office. </i></b>

</p>

</section>

<section>

<p>

<h r>

<blockquote>

I was struggling to lose weight after the birth of my second child. My friend recommended NewYou, and after the first three months I

had lost 3 0 pounds. Thanks to the personal attention from their trainers and counselors, I’ve been able to keep the weight off for two

years. I’m in the best shape of my life!

<b r>

<cite>—Justine Reynolds, Cleveland</cite>

</blockquote>

<h r/>

</p>

</section>

<section>

<address>

NewYou Personal Training, 3451 West Oxmoor Avenue, Cleveland, TN 37311. (555) 639-9681 or (555) NEW-Y OU1

</address>

</section>

</body>

</html>

project3style.css : ---------->>>>>>>>

/* your name Project 3 */

body{

margin: 50px;

font-family: sans-serif;

background-color: bisque;

}

h2{

color:darkblue;

font-size: 2em;

}

h3{

color: green;

background-color: lightblue;

}

address{

color: red;

text-align: center;

font-style: italic;

font-variant: small-caps;

font-weight: 700;

font-size: 12pt;

line-height: 24pt;

}

blockquote{

background-color: gold;

width: 600px;

padding: 20px;

}

li{

text-transform: capitalize;

line-height: 2;

color: green;

}

3 0
3 years ago
Other questions:
  • When using Microsoft word, what would happen to the text of a paragraph if the "Justify" option is used?
    9·1 answer
  • The Internet began when a large company wanted to sell products online. True False
    15·2 answers
  • The benefits of flextime include:
    11·2 answers
  • Write an expression that computes the average of the values 12 and 40.
    6·1 answer
  • A simulation model includes: a. a description of the components of the system. b. a simulation clock. c. a definition of the sta
    8·1 answer
  • Write a c++ application that computes gross salary for Mr.A,given that during the interview session and before started work, it
    5·1 answer
  • Write the SQL query that would search a table called Movies and return the titles of movies that were made in 1975.
    7·1 answer
  • Every time attribute A appears, it is matched with the same value of attribute B, but not the same value of attribute C. Therefo
    11·1 answer
  • Write a function that receives a StaticArray and returns an integer that describes whether the array is sorted. The method must
    14·1 answer
  • list three things that can spoil a printer if they are not of the correct specification and explain what damage may be caused​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!