utpl-lÓgica de la programaciÓn-ii bimestre-(octubre 2012-febrero 2013)
TRANSCRIPT
![Page 1: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/1.jpg)
Lógica de la ProgramaciónLógica de la Programación
TITULACIÓN: Escuela de Ciencias de la Computación
BIMESTRE: Segundo
NOMBRES: René Rolando Elizalde Solano
![Page 2: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/2.jpg)
SECCIÓN 1
Algoritmos orientados a datos y miniespecificaciones
2
![Page 3: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/3.jpg)
Aspectos clave Un algoritmo orientado a datos
especifica las operaciones que se debe realizar con los datos.
Su finalidad es hacer conocer al desarrollador los datos que estarán involucrados.
Un algoritmo orientado a datos puede traducirse a miniespecificación.
3
Ejemplo: Se pregunta la edad de un estudiante (edad,i[1-n])
![Page 4: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/4.jpg)
Aspectos clave (2)
Para poder representar la información a usar en los algoritmos orientados a datos tenemos:(Nombre Variable, SímboloTipo [Dominio])
(edad,i[1-n])
4
![Page 5: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/5.jpg)
Aspectos clave (2)
La asignación de una variable se la realiza de la siguiente manera.
NombreVariable ← Expresión
edad ← 10
Se puede usar lo siguiente: (edad,i[1-n]) ← 10
5
![Page 6: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/6.jpg)
Aspectos clave (3)
La representación simbólica de una petición de datos es la siguiente:
>> NombreVariable
Ejemplo:
>> edad
SE USA PUNTA DE FLECHA DOBLE HACIA LA DERECHA
6
![Page 7: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/7.jpg)
Aspectos clave (3)
La forma en que se presenta simbólicamente la muestra de datos es la siguiente:
<< Expresión
Ejemplo
<< edad
ó
<< “la edad de la persona es” + edad
SE USA PUNTA DE FLECHA DOBLE HACIA LA IZQUIERDA
7
![Page 8: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/8.jpg)
Ejemplo
Se desea construir un programa para calcular el sueldo de una persona en función de las horas trabajadas y el valor de la hora.
8
![Page 9: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/9.jpg)
Algoritmo del análisis
1. Inicio
2. Se pregunta el total de horas trabajadas.
3. Se pregunta el costo por hora.
4. Se calcula el valor a pagar multiplicando las horas trabajadas por el costo hora.
5. Se muestra el valor a pagar.
6. Fin
9
![Page 10: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/10.jpg)
Traducción a orientado a datos
1. Inicio
2. Se pregunta las horas trabajadas(Horas,i[1-n])
3. Se pregunta el costo horas (cHora,i[1-n])
4. Se calcula el total (total, i[1-n]) multiplicando el costo por las horas.
5. Se muestra el total
6. Fin.
10
![Page 11: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/11.jpg)
Traducción a mini especificación
1. Inicio
2. (horas,i[1-n])
3. (cHora,i[1-n])
4. (total,i[1-n])
5. << “Indique el total de horas trabajo”
6. >> horas
7. << “Indique el costo hora”
8. >> cHora
11
![Page 12: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/12.jpg)
Traducción a mini especificación (2)
9. total = horas * cHora
10. << “Debe pagar “ + Total
11. Fin
12
![Page 13: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/13.jpg)
SECCIÓN 2
Estructuras de decisión y control
13
![Page 14: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/14.jpg)
Aspectos clave
Estructuras de decisión: estructura de código en la cual una expresión lógica determina la ejecución por ÚNICA VEZ de un bloque
La clásica de las estructuras de decisión es la condicional ( Simple y Compuesta)
14
![Page 15: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/15.jpg)
Aspectos clave
Condicional SIMPLE
Si ExpresiónLógica Entonces
Ejecutar parte del algoritmo si la Expresión es Verdadera
Fin Si
Si edad >= 18 Entonces
<< “Es mayor de edad”Fin Si
15
![Page 16: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/16.jpg)
Aspectos clave
Condicional Compuesta
Si ExpresiónLógica Entonces
Ejecutar parte del algoritmo si la expresión es Verdadera
De lo Contrario
Ejecutar parte del algoritmo si la expresión es Falsa
Fin Si
16
![Page 17: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/17.jpg)
Aspectos clave
Condicional Compuesta
Si edad >= 18 Entonces
<< “Es mayor de edad”De lo Contrario
<< “Es menor de edad”Fin Si
17
![Page 18: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/18.jpg)
Aspectos clave ContadoresTécnicas de cambio de estado en donde una
variable puede contar las veces en que su estado cambia.
Variable ← Variable + 1
Ejemplo
i ← i + 1
i ← i + 1
i ← i + 1
ÚTIL CUANDO YA QUE PERMITE CONOCER CUANTAS VECES UN PROGRAMA HA PASADO
POR UNA DETERMINADA LÍNEA
18
![Page 19: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/19.jpg)
Aspectos clave Acumuladores• Técnicas de cambio de estado en donde una
variable tiene la posibilidad de acumular un valor al valor que ya posee
Variable ← Variable + Expresión
Ejemplo
i ← i + 10
i ← i + 5
i ← i + 3
ÚTIL CUANDO YA QUE PERMITE REALIZAR SUMATORIAS DE VALORES
19
![Page 20: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/20.jpg)
Aspectos clave
Estructuras de Control
Es la estructura de código que permite que una expresión lógica determine la ejecución reiterada de un bloque de código
20
![Page 21: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/21.jpg)
Aspectos clave
Bucle de comparación al INICIO: Se ejecutará siempre y cuando la expresión lógica sea VERDADERA (True)j ← 1
Mientras j <= 10 Entonces
<< “Al pasar por aquí el valor de i es: ” + j
j ← j + 1Fin Mientras
21
![Page 22: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/22.jpg)
Aspectos clave Estructuras de Control• Bucle de comparación al FINAL: Se
ejecutará hasta que la expresión lógica sea VERDADERA (True)
j ← 1
Inicio
<< “Al pasar por aquí el valor de i es: ” + j
j ← j + 1Hasta que j > 10
22
![Page 23: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/23.jpg)
Aspectos clave (2) Una estructura anidada es aquella que
se encuentra dentro de otra estructura de control.
Las pruebas de escritorio permiten verificar el funcionamiento correcto del algoritmo.
23
![Page 24: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/24.jpg)
SECCIÓN 3
Diagramas de flujo
24
![Page 25: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/25.jpg)
SECCIÓN 3
25
Ayudan a visualizar la lógica del programa.
Facilitan la comunicación con otras personas.
Existen equivalencias entre los símbolos y las operaciones de un algoritmo.
![Page 26: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/26.jpg)
Ejemplo
26
![Page 27: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/27.jpg)
Ejemplo
27
![Page 28: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/28.jpg)
28
Practiquemos con preguntas
![Page 29: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/29.jpg)
Pregunta 1
Las siguientes son sentencias en miniespecificación. ¿Cuál declarción establece una la variable v1 como entera con valores del 1 al 1000, excepto los múltiplos de 5?
a. (v1, i[1-n])
b. (v1, i[1-1000])
c. (v1, i[{1-1000}, !{5,10,15,..}])
d.(v1,b[{1-1000}, !{5,10,15,..}])
29
![Page 30: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/30.jpg)
Pregunta 2
¿Cuántas veces se ejecuta el código dentro del siguiente bucle? Siendo N = 3
Mientras (N < 2) Entonces
<< “Este es un bucle”
Fin mientras
a.2
b.0
c. 1
d. Infinito
30
![Page 31: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/31.jpg)
Pregunta 3
En un bucle de comparación al inicio es posible que:
a.Se ejecutan al menos una vez.
b.No se ejecuten las sentencias nunca.
c. Solo ciertas sentencias se ejecuten.
d. Se ejecuten secuencialmente.
31
![Page 32: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/32.jpg)
Pregunta 4
¿Cuál sentencia se ejecuta si lado vale 2?
Si lado >=1 Entonces
AreaCuadrado = lado^2
De lo contrario
<< “El lado no puede ser menor a uno”
Fin si
32
![Page 33: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/33.jpg)
Pregunta 4
a. << “El lado no puede ser menor a uno”
b. >> “El lado no puede ser menor a uno”
c. AreaCuadrado lado^2
d. Ninguna.
33
![Page 34: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/34.jpg)
Pregunta 5
Siendo x una variable entera ¿Cuál de las siguientes sentencias permite su uso como acumulador?
a. x = x ^ 2
b. x = x *y
c. x = x – y
d. x = x + 3
34
![Page 35: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/35.jpg)
Pregunta 6
¿Qué tipo de sentencia representa el siguiente diagrama?
a. Flujo secuencial
b. Una flujo condicional
c. Un bucle de comp. al inicio.
d. Un bucle de comp. al final.
35
![Page 36: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/36.jpg)
![Page 37: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(Octubre 2012-Febrero 2013)](https://reader035.vdocuments.pub/reader035/viewer/2022081420/558434edd8b42ad8268b469c/html5/thumbnails/37.jpg)
PROGRAMA: Tutoría Lógica de la Programación Titulación: Informática
Fecha: 3 de Enero de 2013
Docente: Ing. René Rolando Elizalde Solano
Hora Inicio: 18:00 Hora Final:19:00
GUIÓN DE PRESENTACIÓN
Puntos de la Presentación
Intervienen Duración Aprox. en minutos
Material de Apoyo
Saludo inicial y presentación de la materia
Ing. René Rolando Elizalde Solano
• 5 Sin material.
-Desarrollo del contenido:- Presentación de temas-Resolución de preguntas
Ing. René Rolando Elizalde Solano
• 45 minutos Diapositivas (cambios cada 5 seg.), Cámara documentos.
- Preguntas- Despedida
Ing. René Rolando Elizalde Solano
•10 minutos Correo, teléfono, ext, horario de tutoría.