utpl-lÓgica de la programaciÓn-ii bimestre-(abril agosto 2012)
TRANSCRIPT
![Page 1: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/1.jpg)
Lógica de la Programación
ESCUELA:
NOMBRES:
Escuela de Ciencias de la Computación
Ing. Patricio Abad Espinoza
BIMESTRE: Segundo
![Page 2: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/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-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/3.jpg)
Aspectos clave
Algoritmos orientados a datos: Operaciones a nivel de dato. Flujos de programa secuenciales. Flujos de programa condicionales Flujos de programa repetitivos.
3
![Page 4: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/4.jpg)
4
![Page 5: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/5.jpg)
Estructura de un progama
5
ENTRADAS
DECLARACIONES
PROGRAMA
PROCESOS
SALIDAS
1. Inicio2. (peso, d[0-n])3. (valor, d[0-n])4. (pesoC, i[1-n])5. (impuesto,d[0-n])
6. << "Ingrese el peso en libras"7. >> peso8. << "Ingrese el valor del artículo"9. >> valor
10. impuesto <- 011. Si peso > 10 ó valor > 400 Entonces12. impuesto <- valor*0.1213. Fin Si
14. >> "El impuesto es " + impuesto
15. Fin
![Page 6: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/6.jpg)
Ejercicio
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.
6
![Page 7: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/7.jpg)
Algoritmo del análisis
1. Inicio2. 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
7
![Page 8: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/8.jpg)
Traducción a orientado a datos
1. Inicio2. Se pregunta las horas
trabajadas(totalHoras,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 total6. Fin.
8
![Page 9: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/9.jpg)
Traducción a mini especificación
1. Inicio2. (Horas,i[1-n])3. (cHora,i[1-n])4. (total,i[1-n])5. << “Indique el total de horas trabajo”6. >> Horas7. << “Indique el costo hora”8. >> cHora
9
![Page 10: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/10.jpg)
Traducción a mini especificación (2)
9. Total Horas * cHora10. << “Debe pagar “ + Total11. Fin
10
![Page 11: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/11.jpg)
SECCIÓN 2
Estructuras de control Selectivas Bucles
11
![Page 12: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/12.jpg)
Aspectos clave
Las estructuras de control permiten alterar el flujo del programa.
Las estructuras condicionales pueden ser simples y compuestas.
Los bucles son de comparación al inicio y de comparación al final.
Los bucles de comparación al inicio se ejecutan si la condición de entrada es verdadera.
12
![Page 13: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/13.jpg)
Aspectos clave (2) Los bucles de comparación al final se
ejecutan si la condición es falsa. Una estructura anidada es aquella que
se encuentra dentro de otra estructura de control.
Se debe usar las estructuras de control según sea necesario.
Las pruebas de escritorio permiten verificar el funcionamiento correcto del algoritmo.
13
![Page 14: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/14.jpg)
Aspectos clave (3) Las variables enteras pueden usarse
como acumuladores o como contadores. Los contadores ayudan a establecer el
numero de ocurrencias de un evento e incrementan de 1 en 1.
Los acumuladores guardan valores de varias corridas y permiten hacer cálculos globales.
14
![Page 15: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/15.jpg)
Ejercicio
El mcd de dos números es el mayor número que puede dividir exactamente a ambos. Desarrolle una diagrama de flujo que le permita obtener este número, los números se ingresan por teclado.
15
![Page 16: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/16.jpg)
Miniespecificación
Inicio (mcd, i[1-n]) (num1,i[1-n]) (num2, i[1-n]) << “Numero 1” >> num1 << “Numero 2” >> num2
16
![Page 17: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/17.jpg)
Miniespecificación
1. Fin mientras.2. << “El mcd es” + mcd.3. Fin
Corrida manual
17
![Page 18: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/18.jpg)
Miniespecificación
9. Si num1 < num210. mcd num111. Caso Contrario4. mcd num25. Fin Si6. Mientras (num1 % mcd != 0) and7. (num2 % mcd != 0)8. mcd mcd – 1
18
![Page 19: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/19.jpg)
SECCIÓN 3
Diagramas de flujo
19
![Page 20: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/20.jpg)
Aspectos clave
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.
20
![Page 21: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/21.jpg)
Ejemplo
21
![Page 22: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/22.jpg)
Practiquemos con preguntas
22
![Page 23: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/23.jpg)
Pregunta 1
Las siguientes son sentencias en miniespecificación. ¿Cuál declaració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,..}])
23
![Page 24: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/24.jpg)
Pregunta 2
¿Cuántas veces se ejecuta el código dentro del siguiente bucle? Siendo N = 3 Mientras (N < 2) << “Este es un bucle” Fin mientras
a.2b.0c. 1
d. Infinito 24
![Page 25: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/25.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.
25
![Page 26: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/26.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
26
![Page 27: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/27.jpg)
Pregunta 4
a. << “El lado no puede ser menor a uno”b. >> “El lado no puede ser menor a uno”c. AreaCuadrado lado^2d. Ninguna.
27
![Page 28: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/28.jpg)
Pregunta 5
Siendo x una variable entera ¿Cuál de las siguientes sentencias permite su uso como acumulador?
a. x = x ^ 2b. x = x *yc. x = x – yd. x = x + 3
28
![Page 29: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/29.jpg)
Pregunta 6
¿Qué tipo de sentencia representa el siguiente diagrama?a. Flujo secuencialb. Una flujo condicionalc. Un bucle de comp. al inicio.d. Un bucle de comp. al final.
29
![Page 30: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/30.jpg)
![Page 31: UTPL-LÓGICA DE LA PROGRAMACIÓN-II BIMESTRE-(abril agosto 2012)](https://reader033.vdocuments.pub/reader033/viewer/2022052307/55a05eab1a28ab462e8b4637/html5/thumbnails/31.jpg)
PROGRAMA: Tutoría Lógica de la Programación Carrera: Informática
Fecha: 26 de junio de 2012
Docente: Ing. Patricio Abad Espinoza
Hora Inicio: 19:15 Hora Final: 20:15
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. Patricio Abad Espinoza
• 5 Sin material.
-Desarrollo del contenido:- Presentación de temas-Resolución de preguntas
Ing. Patricio Abad Espinoza.
• 45 minutos Diapositivas (cambios cada 5 seg.), Cámara documentos.
- Preguntas- Despedida
Ing. Patricio Abad Espinoza.
•10 minutos Correo, teléfono, ext, horario de tutoría.