Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #pregunta1
- def mayor(d):
- return max(d.values())
- #pregunta2
- def llena_diccionario():
- clave = input()
- val = input()
- d = {}
- while clave != "x":
- d[clave] = val
- clave = input()
- val = input()
- return d
- #pregunta3
- def listas_diccionario(claves, valores):
- d = {}
- for i, j in zip(claves, valores):
- d[i] = j
- return d
- def mes_letras(n):
- if n < 1 or n > 12:
- return "Mes no valido"
- d = {1: "Enero", 2: "Febrero", 3: "Marzo", 4: "Abril", \
- 5: "Mayo", 6: "Junio", 7: "Julio", 8: "Agosto", \
- 9: "Setiembre", 10: "Octubre", 11: "Noviembre", 12: "Diciembre"}
- return d[n]
- def mes_numero(mes):
- if mes not in ["Enero", "Febrero", "Marzo", "Abril", \
- "Mayo", "Junio", "Julio", "Agosto", \
- "Setiembre", "Octubre", "Noviembre", "Diciembre"]:
- return "Mes no valido"
- d = {"Enero": 1, "Febrero": 2, "Marzo": 3, "Abril": 4, \
- "Mayo": 5, "Junio": 6, "Julio": 7, "Agosto": 8, \
- "Setiembre": 9, "Octubre": 10, "Noviembre": 11, "Diciembre": 12}
- return d[mes]
- def cuenta_palabras(text):
- palabras = text.split(" ")
- d = {}
- for i in palabras:
- if i in d.keys():
- d[i] += 1
- else:
- d[i] = 1
- return d
- def cuenta_letras(text):
- d = {}
- for i in text:
- if i in d.keys():
- d[i] += 1
- else:
- d[i] = 1
- return d
- #test pregunta1
- #test = {1: 10, 2: 5, 3:8}
- #print(mayor(test))
- #test pregunta2
- #print(llena_diccionario())
- #test pregunta3
- #claves = [1, 2, 3, 4, 5]
- #valores = ["Enero", "Febrero", "Marzo", "Abril", "Mayo"]
- #print(listas_diccionario(claves, valores))
- #test pregunta4
- #print(mes_letras(8))
- #print(mes_letras(15))
- #test pregunta5
- #print(mes_numero("x"))
- #print(mes_numero("Agosto"))
- #test pregunta6
- #print(cuenta_palabras("si si si no juan pedro maria no si"))
- #test pregunta7
- #print(cuenta_letras("si si si no juan pedro maria no si"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement