¿Cómo comprobar un número usando el bucle for en Python? Ejemplos + ejercicios
#pythonespañol #buclesforpython #cuantosnumeroshayenlalista #magicnumber
Ejercicios:
1. ¿Cuántos números hay en esta lista?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
2. ¿Cuántos del número
212
102
100
111
hay en esta lista?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
Para resolver la tarea hay que usar el bucle for.
______________________________________________________________________________________
Recordemos los bucles. Ya estábamos hablando de ellos en el primer curso de Python.
¿Cómo contar el número de elementos en una lista usando el bucle for en Python?
La lista del ejemplo:
[19,3,19,22]
A veces reemplazamos la variable de iteración por el guión bajo.
¿Cuántos números 19 hay en esta lista [19,3,19,22]?
Creamos una nueva variable y la nombramos NUMBER_TO_CHECK para evitar la situación con el "número mágico" - "magic number".
Curso №2 de Python en español 9
Curso de programación en Python en español
Видео ¿Cómo comprobar un número usando el bucle for en Python? Ejemplos + ejercicios канала Olga Soboleva
Ejercicios:
1. ¿Cuántos números hay en esta lista?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
2. ¿Cuántos del número
212
102
100
111
hay en esta lista?
[212, 111, 102, 201, 212, 122, 210, 101, 211, 222, 212, 202, 102, 211, 201, 212, 110, 212, 220, 221, 102, 121]
Para resolver la tarea hay que usar el bucle for.
______________________________________________________________________________________
Recordemos los bucles. Ya estábamos hablando de ellos en el primer curso de Python.
¿Cómo contar el número de elementos en una lista usando el bucle for en Python?
La lista del ejemplo:
[19,3,19,22]
A veces reemplazamos la variable de iteración por el guión bajo.
¿Cuántos números 19 hay en esta lista [19,3,19,22]?
Creamos una nueva variable y la nombramos NUMBER_TO_CHECK para evitar la situación con el "número mágico" - "magic number".
Curso №2 de Python en español 9
Curso de programación en Python en español
Видео ¿Cómo comprobar un número usando el bucle for en Python? Ejemplos + ejercicios канала Olga Soboleva
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Filtering in a loop: example + exercise 3](https://i.ytimg.com/vi/7IKC4prx9CM/default.jpg)
![Grundkonzepte der Programmiersprache Python](https://i.ytimg.com/vi/vzJFXiDaBWA/default.jpg)
![Summing elements in a list using a loop "for" in Python: example + exercise 6](https://i.ytimg.com/vi/ZL75f3jqsAs/default.jpg)
![Konditionale Schritte in Python: Aufgabe 5](https://i.ytimg.com/vi/QbFLe2f1Nc8/default.jpg)
![Buscamos el valor mayor en una lista usando la palabra clave None en Python: ejemplo + ejercicio 11](https://i.ytimg.com/vi/nydOjKo28VU/default.jpg)
![Порядок выполнения действий в программировании и математике](https://i.ytimg.com/vi/6BQNYYHYGjA/default.jpg)
![Palabra clave "in" en Python. ¿Cómo aplicar "in" a strings en Python?](https://i.ytimg.com/vi/Ah_iaC8w6pA/default.jpg)
![Order of operations in programming and mathematics](https://i.ytimg.com/vi/8KVWbptzwj4/default.jpg)
![Counting elements in a list using a for loop in Python: example + exercise 5](https://i.ytimg.com/vi/vtS12NIoAWU/default.jpg)
![Structure "try and except" in Python: exercise 1 - a hotel](https://i.ytimg.com/vi/jltzq6YUpf0/default.jpg)
![Creación del bucle "for" en Python](https://i.ytimg.com/vi/j-24VLm1HAE/default.jpg)
![Упражнения на циклы в Python - проверьте себя](https://i.ytimg.com/vi/BK_LsClDm1Q/default.jpg)
![Python: la estructura del curso número 1](https://i.ytimg.com/vi/x63Ic81f6xM/default.jpg)
![Strings in Python. String concatenation in Python.](https://i.ytimg.com/vi/HbrGRoD0Uww/default.jpg)
![Python: Struktur des Kurses Nummer 1](https://i.ytimg.com/vi/Y8ZRyG9no2k/default.jpg)
![Индексы в строках в Python: оператор индексации [ ]](https://i.ytimg.com/vi/t_KpQr7MXxI/default.jpg)
![Variablen in Python](https://i.ytimg.com/vi/of1DqlZ6_UY/default.jpg)
![Bauen eigene Funktionen in Python: die Übung "Die Punktezahl und die Note"](https://i.ytimg.com/vi/I10mUBJCOK8/default.jpg)
![Johann Sebastian Bach: Sinfonia No. 4 in D Minor (BWV 790), celesta sound](https://i.ytimg.com/vi/SeCViPj1XtM/default.jpg)
![Como abrir y leer ficheros en Python](https://i.ytimg.com/vi/OsapBqsvLgU/default.jpg)
![String libraries and string methods in Python; dir() function in Python](https://i.ytimg.com/vi/fDgjpyxhxFM/default.jpg)