Diferencia entre revisiones de «Curso Python DGA 2011/inmersion python/ejercicios clase/ejercicios dia1»
De WikiEducator
| Línea 1: | Línea 1: | ||
| + | {{TEP}} | ||
| + | |||
{{Actividad| | {{Actividad| | ||
Title=Primeros ejercicios| | Title=Primeros ejercicios| | ||
| Línea 15: | Línea 17: | ||
{{Actividad| | {{Actividad| | ||
| − | Title= | + | Title=Más madera!!!| |
| − | # | + | <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> | ||
| + | </ol> | ||
}} | }} | ||
Revisión de 16:22 15 ago 2011
| Trabajo en proceso, espera cambios frecuentes. Tu ayuda y retroalimentación son bienvenidos. Ver página de charlas. |
Tip: Descarga los archivos del repositorio gitghub del curso.
|
|