[Tutor] On off Toggle

Adrian Atkinson admatkin at umail.iu.edu
Sat Mar 12 04:05:41 CET 2011


class Television(object):
    def __init__(self,__channel,volume,is_on):
        self.volume = volume
        self.is_on = "Power is off"
        power = self.is_on

    def toggle_power(self):

        if choice == "1" and power == self.is_on  :
            power = "Power is Now on"
        elif choice =="1" and power =="Power is Now on" :
            power = self.is_on
        print power
    def instructions():
        print "0 - Exit"
        print "1 - Toggle Power"
        print "2 - Change Channel"
        print "3 - Raise Volume"
        print "4 - Lower Volume"
#Main

choice = ""


while choice != 0:
    choice = raw_input("Can I have a selection number? : ")
    tv = Television(0,50,"is_on")
    tv.toggle_power()




I'm trying to make a toggle to turn the power on and off in the toggle_power
method
but I cannot figure  this out. Any help would be greatly appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110311/ba3cd4de/attachment.html>


More information about the Tutor mailing list