def run(): #OBJETO LAMPARA lamp = Lamp(is_turned_on=False) ventilador_con_lampara = VentiladorConLampara(vent_status=True, lamp_status=True) while True: command = str( input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() ventilador_con_lampara.encender_ventilador(True) ventilador_con_lampara.turn_on() elif command == 'a': lamp.turn_off() ventilador_con_lampara.encender_ventilador(False) ventilador_con_lampara.turn_off() else: break
def run(): lamp = Lamp(is_turned_on=False) while True: command = input( "Digite 1 para prender, 2 para apagar y 3 para salir: ") if command == "1": lamp.turn_on() elif command == "2": lamp.turn_off() else: break
def run(): lamp = Lamp(is_turned_on=False) while True: command = str(input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() else: break
def run(): #lamp1 = lamp.Lamp(is_turned_on=False) lamp1 = Lamp(is_turned_on=False) while True: command = input(''' What so you want to do? [1] Turn ON [0] Turn OFF [3] Exit ''') if command == '1': lamp1.turn_on() lamp1._display_image() elif command == '0': lamp1.turn_off() else: break
def run(): lamp = Lamp(is_turned_on=False) while True: command = str( input(''' What do you want to do? [o]On [f]Off [e]Exit ''')) if command == 'o': lamp.turn_on() elif command == 'f': lamp.turn_off() else: quit()
def run(): lamp = Lamp(is_turned_on=False) while True: command = input(""" ¿Que deseas hacer? [p]render [a]pagar [s]salir """) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() else: break
def run(): # intanciar la clase lamp = Lamp(is_turned_on=False) while True: command = input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''') if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() else: sys.exit()
def run(): lamp = Lamp(is_turned_on=False) #lamp = Lamp(True) No se utiliza por convención, ya que no indica a que variable se está asignando. while True: command = str(input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() else: break
def run(): lamp = Lamp(_is_turn_on=False) while True: command = str( input(''' choose an option 1. turn on 2. to turn off 3. exit ''')) if command == '1': lamp.turn_on() elif command == '2': lamp.turn_off() else: break
def run(): lamp = Lamp(is_turned_on=True) #inicializar una clase while True: command = str( input(''' ¿Que deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() else: break
def run(): lamp = Lamp(is_turned_on=False) while (True): command = str( raw_input(''' Input one of the following commands: turn o[n] turn of[f] [e]xit ''')) if command == 'n': lamp.turn_on() elif command == 'f': lamp.turn_off() elif command == 'e': return else: print('Can\'t understand your input')
def run(): lamp = Lamp(is_turned_on=False) while True: menu = str( input(""" 😁Bienvenido que deseas hacer?😎 1.- Encender la lampara 2.- Apagar la lampara 3.- Salir Escribe tu opcion aqui: """)) if menu == '1': lamp.turn_on() elif menu == '2': lamp.turn_off() elif menu == '3': print("Haz salido del sistema") return False else: print("Eligue una opcion correcta!")
def menu(): lamp = Lamp(is_turned_on=False) while True: command = str( input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() elif command == 's': print('Adios :b') break else: print('Opcion nula')
def main(): lamp = Lamp(is_turned_on=False) while True: command = str( input(''' What do dou wanna do? [ON] Turn on [OFF] Turn off [E] Exit Enter your selection: ''')).upper() if command == 'ON': lamp.turn_on() elif command == 'OFF': lamp.turn_off() elif command == 'E': break else: print('\n INVALID OPTION! \n')
def run(): lamp = Lamp(is_turned_on=True) while True: command = str( input(''' ¿Qué deseas hacer? [p]render [a]pagar [s]alir ''')) if command == 'p': lamp.turn_on() elif command == 'a': lamp.turn_off() elif command == 's': break else: print('\nIngresa un comando válido!') time.sleep(1) os.system('cls')
import os from lamp import Lamp if __name__ == '__main__': lamp = Lamp(False) while True: opt = int( input(''' Choose an option: 0. Turn off 1. Turn on 2. Exit ''')) if opt == 0: lamp.turn_off() elif opt == 1: lamp.turn_on() elif opt == 2: break else: os.system('clear') print('Invalid option')
class Machine: def __init__(self): self.alarms = [] self.alarms_dict = {"alarms": []} self.led = Lamp() self.audio = Audio() def init_alarm(self, hour, minutes, days=[1, 2, 3, 4, 5]): self.alarms.append(Alarm(hour, minutes, days)) self.dump_alarms() def dump_alarms(self): all_alarms = [] for a in self.alarms: d = { "hour": a.hour, "minute": a.minute, "days": a.days, } all_alarms.append(d) self.alarms_dict["alarms"] = all_alarms with open('alarms.json', 'w') as f: json.dump(self.alarms_dict, f) def load_alarms(self): with open('alarms.json', 'r') as f: self.alarms_dict = json.load(f) self.alarms = [] for i in range(len(self.alarms_dict["alarms"])): hour = self.alarms_dict["alarms"][i]["hour"] minutes = self.alarms_dict["alarms"][i]["minute"] days = self.alarms_dict["alarms"][i]["days"] self.alarms.append(Alarm(hour, minutes, days)) def wake_up(self): self.led.sunrise() now = datetime.datetime.now().replace(tzinfo=tz) h = now.hour m = now.minute t = "{0:02}:{1:02}".format(h, m) day = now.day months = [ "January", "February", "Mars", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] month = months[now.month - 1] try: temp, temp_feels, weather = get_weather() message = f"Good morning Linus, It is {t} on the {day} of {month},,, The temperature outside is {temp} " \ f"degrees and feels like {temp_feels} " \ f"degrees and the weather status is {weather},,, " except: message = f"Good morning Linus, It is {t} on the {day}. of {month},,, The weather data is unavailable,,, " try: cal_message = get_calendar_message() message += cal_message except Exception as e: print(e) message += "I could not get today's events, please have a look on your own." message += "Stand by for the news." get_file() self.audio.say(message) self.audio.play_podcast() self.led.turn_off() def main(self): while True: self.load_alarms() print(datetime.datetime.now().replace(tzinfo=tz)) for alarm in self.alarms: print(alarm.hour) if alarm.check() or OS == "Darwin" or debug: print("waking up") self.wake_up() time.sleep(30)