-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathnotas.py
More file actions
39 lines (29 loc) · 774 Bytes
/
notas.py
File metadata and controls
39 lines (29 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
class Notas():
def __init__(self):
self._notas={}
@property
def notas(self):
resultado=""
for key,value in self._notas.items():
resultado+=key+":"+str(value)+"\n"
return resultado
def addnotas(self,asig,nota):
self._notas[asig]=nota
def modnota(self,asig,nota):
if asig in self._notas.keys():
self._notas[asig]=nota
else:
raise ValueError("Asignatura incorrecta")
def delnota(self,asig):
if asig in self._notas.keys():
del self._notas[asig]
else:
raise ValueError("Asignatura incorrecta")
def media(self):
return sum(self._notas.values())/len(self._notas.values())
def __str__(self):
resultado=""
for key,value in self._notas.items():
resultado+=key+":"+str(value)+"\n"
return resultado