Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

--Plese write the following in Python language(as simple as possible also) -- Wr

ID: 3685519 • Letter: #

Question

--Plese write the following in Python language(as simple as possible also)

-- Write the definition of a class Counter containing:

•An instance variable named counter of type int.

•A constructor that takes one int argument and assigns its value to counter

•A method named increment that adds one to counter. It does not take parameters or return a value.

•A method named decrement that subtracts one from counter. It also does not take parameters or return a value.

•A method named get_value that returns the value of the instance variable counter.

Explanation / Answer

class Counter:
int counter
def _init_(self,cc):
self.counter=cc
def increment(self):
self.counter += 1
def decrement(self):
self.counter -= 1
def get_value(self):
return self.counter