Diferencia entre revisiones de «Curso Python DGA 2011/inmersion python/ejercicios clase/ejercicios dia1»
De WikiEducator
| (7 revisiones intermedias por el mismo usuario no mostrado) | |||
| Línea 1: | Línea 1: | ||
{{Actividad| | {{Actividad| | ||
| − | Title=Primeros ejercicios | + | Title=Primeros ejercicios| |
| − | tip= | + | tip=Ayuda para easygui: [[Curso Python DGA 2011/inmersion python/chuleta easygui | chuleta easygui]]| |
| + | * Sigue los modelos que tienes aquí: https://github.com/neodoo/curso_python_dga_11/tree/master/inmersion/dia1 | ||
| + | * Copia el código de los ejercicios en el editor y completa las tareas. | ||
| + | |||
# ej1_1.py ''(print)'' | # ej1_1.py ''(print)'' | ||
# ej1_2.py ''(raw_input, print)'' | # ej1_2.py ''(raw_input, print)'' | ||
| Línea 11: | Línea 14: | ||
# adivina_numero.py ''(comparaciones, repeticiones)'' | # adivina_numero.py ''(comparaciones, repeticiones)'' | ||
# ordena_nombres.py ''(listas, ordenación)'' | # ordena_nombres.py ''(listas, ordenación)'' | ||
| + | # muestra_archivo.py ''(lectura archivos)'' | ||
| + | }} | ||
| + | |||
| + | |||
| + | {{Actividad| | ||
| + | Title=Más ejercicios| | ||
| + | <ol> | ||
| + | <li>Crea el modulo temperatura para que funcionen los siguientes tests: | ||
| + | <source lang="python"> | ||
| + | import nose | ||
| + | import temperatura | ||
| + | |||
| + | def test_freezing(): | ||
| + | '''Test freezing point.''' | ||
| + | assert to_celsius(32) == 0 | ||
| + | |||
| + | def test_boiling(): | ||
| + | '''Test boiling point.''' | ||
| + | assert to_celsius(212) == 100 | ||
| + | |||
| + | def test_roundoff(): | ||
| + | '''Test that roundoff works.''' | ||
| + | assert to_celsius(100) == 38 # NOT 37.777... | ||
| + | |||
| + | def test_above_freezing(): | ||
| + | '''Test function for above_freezing.''' | ||
| + | assert above_freezing(89.4), 'A temperature above freezing.' | ||
| + | assert not above_freezing(-42), 'A temperature below freezing.' | ||
| + | assert not above_freezing(0), 'A temperature at freezing.' | ||
| + | |||
| + | if __name__ == '__main__': | ||
| + | nose.runmodule() | ||
| + | </source> | ||
| + | </li> | ||
| + | <li>Población en Zaragoza de los 10 países más representativos en 2010 | ||
| + | * localiza el archivo copiado en el repositorio (''' zaragoza_2010_10.csv''', Información del Ayto. Zaragoza) | ||
| + | * analiza el formato | ||
| + | * Muestra su contenido bien tabulado en pantalla (la primera línea no) | ||
| + | * Comprueba que las sumas de población están bien hechas. | ||
| + | * Guarda en un nuevo archivo sólo la información de países y totales. | ||
| + | </li> | ||
| + | </ol> | ||
}} | }} | ||
Última revisión de 21:19 1 sep 2011
Tip: Ayuda para easygui: chuleta easygui
|
|