Diferencia entre revisiones de «Curso Python DGA 2011/inmersion python/ejercicios clase/ejercicios dia1»

De WikiEducator
Saltar a: navegación, buscar
Línea 1: Línea 1:
 +
{{TEP}}
 +
 
{{Actividad|
 
{{Actividad|
 
Title=Primeros ejercicios|
 
Title=Primeros ejercicios|
Línea 15: Línea 17:
  
 
{{Actividad|
 
{{Actividad|
Title=Ejercicios adicionales|
+
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 04:22 16 ago 2011

Road Works.svg Trabajo en proceso, espera cambios frecuentes. Tu ayuda y retroalimentación son bienvenidos.
Ver página de charlas.
Road Works.svg




Icon activity.jpg

Primeros ejercicios

  1. ej1_1.py (print)
  2. ej1_2.py (raw_input, print)
  3. crea_nombre_usuario.py (strings, doctests)
  4. media_notas.py (raw_input, operaciones)
  5. media_notas_gui.py (con easygui)
  6. cuenta_vocales.py (if, variables)
  7. duracion_canciones.py (tuplas, operaciones)
  8. adivina_numero.py (comparaciones, repeticiones)
  9. ordena_nombres.py (listas, ordenación)


Icon present.gif
Tip: Descarga los archivos del repositorio gitghub del curso.





Icon activity.jpg

Más madera!!!

  1. Crea el modulo temperatura para que funcionen los siguientes tests:
    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()