1. Clases y objetos

1class Television:
2    def __init__(self):
3        self.conectado = False
4        self.canal = 2
5
6
7tv_cuarto = Television()
8tv_sala = Television()
9print(tv_cuarto.conectado)
10print(tv_cuarto.canal)
11tv_sala.conectado = True
12tv_sala.canal = 5
13print(tv_sala.conectado)
14print(tv_sala.canal)
line that just executed

next line to execute

Print output (drag lower right corner to resize)
Frames
Objects

Activity: CodeLens 1.1 (cl_l25_1a)

1class Television:
2    def __init__(self):
3        self.conectado = False
4        self.canal = 2
5
6    def cambiar_canal_hacia_abajo(self):
7        self.canal -= 1
8
9    def cambiar_canal_hacia_arriba(self):
10        self.canal += 1
11
12
13tv = Television()
14tv.cambiar_canal_hacia_arriba()
15tv.cambiar_canal_hacia_arriba()
16print(tv.canal)
17tv.cambiar_canal_hacia_abajo()
18print(tv.canal)
line that just executed

next line to execute

Print output (drag lower right corner to resize)
Frames
Objects

Activity: CodeLens 1.2 (cl_l25_1b)

You have attempted 1 of 2 activities on this page