01/04/20 Ing. Roberto Martínez Román - [email protected]1 TOMANDO DECISIONES La instrucción if Ing. Roberto Martínez Román - [email protected]1 Las estructuras de control Ing. Roberto Martínez Román - [email protected]¨ Las estructuras de control se utilizan para definir la secuencia de ejecución de las instrucciones. Hay 3 estructuras: ¤ Secuencia. Hacer una instrucción después de la otra. ¤ Selección . Ejecutar, o no. instrucciones dependiendo de si se cumple, o no, una condición. ¤ Iteración (ciclos). Ejecutar de manera repetitiva instrucciones. 2
15
Embed
TOMANDO DECISIONES · 2020. 4. 2. · TOMANDO DECISIONES La instrucción if Ing. Roberto Martínez Román [email protected] 1 Las estructuras de control Ing. Roberto Martínez Román
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
¨ Las estructuras de control se utilizan para definir la secuencia de ejecución de las instrucciones. Hay 3 estructuras:¤ Secuencia. Hacer una instrucción después de la otra.
¤Selección. Ejecutar, o no. instrucciones dependiendo de si se cumple, o no, una condición.
¤ Iteración (ciclos). Ejecutar de manera repetitiva instrucciones.
¨ Escribe un programa que lee la carrera de un alumno (LAD, LCMD). Si la carrera es LAD imprimes el mensaje "Estás en el salón correcto"; si es LCMD imprimes el mensaje "Estás en el salón correcto". Si no es ninguno de los dos, imprimes el mensaje "Estás en el salón incorrecto"
Escribe un programa con funciones que haga lo siguiente:¨ Carga una imagen desde el disco.¨ Clasifica la imagen en uno de dos tipos:
¤ Portrait.¤ Landscape.
¨ Clasifica la imagen en una de 3 categorías:¤ Pequeña. Número de pixeles menor o igual a 16,000.¤ Mediana. Número de pixeles mayor a 16,000 pero, menor
a 300,000.¤ Grande. Número de pixeles mayor o igual a 300,000.
¨ Dibuja un diagrama de flujo para resolver cada uno de los siguientes problemas:¤ Leer dos números enteros e imprimir el mayor. ¤ Leer tres números enteros e imprime el mayor.¤ Leer cuatro números enteros e imprime el mayor.
¨ Escribe una función que valide si una calificación es correcta. Regresa True si es correcta, False en otro caso. Es correcta si se encuentra en el rango [0, 100].
¨ Escribe una función que valide si una calificación es aprobatoria. Es aprobatoria si está en [70, 100]
¨ Escribe una función que recibe como parámetro una calificación entera. Regresa una cadena indicando: "Reprobado", "Aprobado" o "Error".
¨ Escribe una función que recibe un valor entero y regresa True si es par, False en otro caso.
¨ Escribe una función que recibe tres parámetros que representan los lados de un triángulo. Regresa True si es un triángulo rectángulo, False en otro caso.
¨ Escribe un programa que usa una función para resolver la ecuación de segundo grado. Si hay raíces reales las calcula y las imprime; si no, calcula e imprime las raíces complejas. La función recibe los tres coeficientes como parámetros.
¿Sabes en qué día de la semana naciste?Escribe un programa que pregunta al usuario su fecha de nacimiento (día, mes, año) y que imprima el día de la semana que corresponda a esa fecha. TODAS LAS DIVISIONES SON ENTERAS.
If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if one of the sticks is 12 inches long and the other two are one inch long, it is clear that you will not be able to get the short sticks to meet in the middle. For any three lengths, there is a simple test to see if it is possible to form a triangle:
¤ If any of the three lengths is greater than the sum of the other two, then you cannot form a triangle. Otherwise, you can. (If the sum of two lengths equals the third, they form what is called a “degenerate” triangle.)
¨ Write a function named isTriangle that takes three integers as arguments, and that returns either True or False, depending on whether you can or cannot form a triangle from sticks with the given lengths.
¨ Write a function main that prompts the user to input three stick lengths, converts them to integers, and uses isTriangle to check whether sticks with the given lengths can form a triangle.
¨ CHALLENGE: If triangle exists, draw it. JThink Python.
How to Think Like a Computer ScientistAllen B. Downey