Python - POO error

 
Vista:

POO error

Publicado por MAtias (3 intervenciones) el 24/04/2019 02:38:15
En un vivero se desea saber mediante los instrumentos instalados la humedad y la temperatura del ambiente.

codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python
#coding=utf-8
import sys
class Mediciones:
    temperatura1 = "22ºC"
    humedad1 = "33%"
    def temperatura (self):
        self.a = temperatura1
        return a
    def humedad (self):
        self.b = humedad1
        return b
medicion1 = Mediciones()
medicion1.a()
medicion1.b()
 
print medicion1.a
print  medicion1.b
error:
Traceback (most recent call last):
File "poo.py", line 14, in <module>
medicion1.a()
AttributeError: Mediciones instance has no attribute 'a'

Llevo mucho tiempo y ya me dí por vencido.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 2.808
Oro
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

POO error

Publicado por tincopasan (1082 intervenciones) el 24/04/2019 04:39:24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
 
class Mediciones:
 
    def temperatura (self):
        temperatura1 = "22ºC"
        self.a = temperatura1
 
        return self.a
 
    def humedad (self):
        humedad1 = "33%"
        self.b = humedad1
 
        return self.b
 
medicion1 = Mediciones()
medicion1.temperatura()
medicion1.humedad()
 
print (medicion1.a)
 
print (medicion1.b)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar