Listing 10 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 10\10.1423 - No Title.py
# Description: No Title
##############################################################################

class Television:
    def __init__(self, channel_min, channel_max):
        self.on = False
        self.channel = 2
        self.channel_min = channel_min
        self.channel_max = channel_max
    def change_channel_down(self):
        if self.channel - 1 >= self.channel_min:
            self.channel -= 1
    def change_channel_up(self):
        if self.channel + 1 <= self.channel_max:
            self.channel += 1
tv = Television(1, 99)
for x in range(0, 120):
    tv.change_channel_up()
print(tv.channel)
for x in range(0, 120):
    tv.change_channel_down()
print(tv.channel)
Click here to download the file