Tutorial de algoritmos de programación | Cursos Platzi
Summary
TLDRThis video teaches the basics of programming using a Pokémon battle as an example. It explains how to create an algorithm for a Pokémon fight, covering key programming concepts like objects, variables, and loops. The instructor walks through the process step-by-step, showing how Pikachu and Jigglypuff battle until one is defeated. This lesson aims to simplify programming by relating it to a familiar and engaging context, making it accessible even for beginners. The video is part of a free online programming course offered by Mejorándola on the Platzi platform.
Takeaways
- 🔄 Programming is like understanding the flow of any process.
- 🐾 The example uses Pokémon to illustrate programming concepts.
- 💡 Pokémon battles are turn-based, making it easier to explain algorithm cycles.
- 📝 Each Pokémon is considered an object in programming with attributes like name, health, and attack power.
- 📊 Variables are used to store data, like the health of each Pokémon.
- 🔄 A cycle (loop) continues as long as certain conditions (like health > 0) are met.
- ⚔️ On each turn, a Pokémon attacks, reducing the opponent's health by its attack power.
- 🔀 The turn variable switches between 1 and 0 to alternate between Pokémon.
- ✅ The loop ends when one Pokémon's health drops to zero or below.
- 🏆 After the loop, the program checks which Pokémon is still alive to determine the winner.
Q & A
What is the main topic discussed in the script?
-The script discusses the basics of programming using a Pokémon battle as an analogy to explain concepts like objects, variables, conditions, and loops.
How does the speaker use Pokémon to explain programming?
-The speaker uses a Pokémon battle between Pikachu and Jigglypuff to illustrate how programming works, including the use of objects to represent Pokémon, variables to store their attributes, and loops to manage the turn-based battle sequence.
What are the key programming concepts introduced in the script?
-The key programming concepts introduced are objects, variables, conditions, loops, and how to assign and manipulate values within a program.
How does the speaker define an object in programming?
-An object in programming is defined as something that has properties and behaviors. In the example, each Pokémon is an object with properties like name, life (health points), and attack power.
What variables are used to represent the Pokémon's attributes in the example?
-The variables used are 'name' for the Pokémon's name, 'life' for their health points, and 'attack' for their attack power.
What is the initial life and attack power of Pikachu and Jigglypuff in the example?
-Pikachu starts with a life of 100 and an attack power of 55. Jigglypuff also starts with a life of 100 but has an attack power of 45.
How is the turn-based battle managed in the script?
-The turn-based battle is managed using a variable called 'turn'. If 'turn' equals 1, it is Pikachu's turn to attack; if 'turn' equals 0, it is Jigglypuff's turn.
What happens during each turn of the battle?
-During each turn, the attacking Pokémon reduces the opponent's life by its attack power. The turn variable is then switched to allow the other Pokémon to attack in the next cycle.
What condition is checked to continue or end the battle?
-The battle continues as long as both Pokémon have a life greater than 0. If either Pokémon's life falls to 0 or below, the battle ends.
How does the script explain the use of loops in programming?
-The script explains that loops in programming are used for repetitive tasks that continue while a condition is true. In the battle example, the loop continues as long as both Pokémon are alive.
What is the outcome of the Pokémon battle in the example?
-Pikachu wins the battle because its attack power is higher, leading to Jigglypuff's life being reduced to below 0 before Pikachu's life is reduced to 0.
How does the script use algebra to explain variable assignments?
-The script uses algebra to explain how variables can hold values that change over time, such as the life points of the Pokémon being updated after each attack.
What is the purpose of the conditional statement at the end of the algorithm?
-The conditional statement at the end of the algorithm checks which Pokémon's life is less than or equal to 0 to determine the winner of the battle.
What additional resources does the speaker mention for learning programming?
-The speaker mentions that the full course, including live classes and practical examples, is available on the educational platform 'Platzi' and encourages viewers to access the JavaScript files for real-world programming practice.
Outlines
🐱💻 Understanding Programming through Pokémon
Programming is as easy as understanding the flow of any process. Using Pokémon as an example, even for those who are not familiar with the game, the concept can be grasped easily. Pokémon involves battles between two creatures. Here, Pikachu and Jigglypuff are used to demonstrate the concept. Both Pokémon have common attributes like names, health (starting at 100), and attack power (Pikachu has 55, Jigglypuff has 45). The battle operates in turns, similar to algebraic variables, where each Pokémon attacks in cycles until one's health drops to zero. The turn system is managed using variables, with Pikachu attacking first. The battle sequence is explained in detail, highlighting how variables and conditions are used to simulate the combat until a Pokémon loses all its health.
🔄 The Pokémon Battle Algorithm
The battle continues with Jigglypuff attacking after Pikachu, reducing Pikachu's health. This cycle repeats until one Pokémon's health drops below zero. The script explains the process in detail, demonstrating how the program evaluates whose turn it is, performs the attack, and updates the health points accordingly. When Jigglypuff's health falls below zero, the cycle ends. The algorithm then checks the final conditions to determine the winner. Pikachu's health remains above zero, indicating its victory. This example encapsulates basic programming concepts like variables, conditions, and loops, providing a foundational understanding for beginners. The course promises to expand on these concepts with practical JavaScript examples, available for free through the provided platform.
Mindmap
Keywords
💡Programar
💡Flujo de proceso
💡Objeto
💡Algebra
💡Variables
💡Ciclos
💡Condiciones
💡Turno
💡Ataque
💡Vida
💡Pikachu
💡Gigli
💡JavaScript
Highlights
Programming is as easy as understanding the flow of any process.
Pokémon battle concept: putting two animals to fight, likened to objects in programming.
Each Pokémon has attributes like name, health (100), and attack power.
Example Pokémon: Pikachu with 55 attack points and Jigglypuff with 45 attack points.
Battle operates in turns: first one Pokémon attacks, then the other.
Declare Pokémon with their health and determine whose turn it is.
Use algebra concepts: variables to store data, like turn and health.
Create a loop for the battle: cycle through attacks until one Pokémon's health is 0 or less.
Steps in the loop: check turn, execute attack, update health, and switch turn.
Example attack sequence: Pikachu attacks Jigglypuff, reducing its health.
Switch turns and continue the loop until one Pokémon's health drops below zero.
When the loop ends, check which Pokémon's health is 0 or less to declare the winner.
Explanation of conditions and loops in programming with the Pokémon battle example.
Learning outcomes: understanding variables, conditions, and loops in programming.
Invitation to a free online programming course with real-world coding examples.
Transcripts
programar es tan fácil como entender el
flujo de cualquier proceso yo les voy a
hablar de pokémon incluso si no les
gusta pokemon e incluso si nunca han
jugado a ningún videojuego en su vida
esto va a ser muy fácil de entender
pokemon es poner a pelear a dos animales
no importa lo que peta piense al
respecto nintendo no ha matado a ningún
animal hasta ahora tienes dos animales
vamos a imaginar que uno es pikachu y el
otro es dirijo picacho y gigli pues son
dos pokemones que van a pelear por sus
vidas y hoy vamos a crear el algoritmo
primero pensemos en cada uno de los
pokemones como algo que en programación
se llama un objeto ambos pokemones
tienen muchas cosas en común los
pokemones tienen nombre pikachu gigli
por los pokemones tienen vida imaginemos
que ambas vidas inician el 100 y los
pokemones también tienen un poder de
ataque picacho es obviamente más
poderoso entonces tiene 55 puntos de
ataque y gigli pop no es tan poderoso
tiene 45 puntos de ataque los puntos de
ataque van a ser los que le quiten vida
al pokemon cuando esté peleando
arrancamos cómo funciona batalla pokemon
por turnos primero
a uno luego pelea el otro así que
declaremos a nuestros pokemones
tendremos a pikachu que tiene una vida
de 100 a gigli porque tiene una vida de
100 y ahora necesitamos saber el turno
de quienes se acuerdan de álgebra no se
preocupen no griten todo va a estar bien
álgebra de hecho es una herramienta
extremadamente útil porque en álgebra
nos enseñaron que son las variables
hagamos una pausa se acuerdan que si x
es igual a 1 y es igual a 2 e imaginemos
que z es igual a x más cuánto vale z con
todo receta 3 porque las variables son
nombres donde se les pueden guardar
datos son cajitas donde podemos guardar
algo volviendo a nuestro a nuestra
batalla pokemon vamos a crear una
variable que recuerde de quién es el
turno vamos a decir que si el turno es
igual a uno le toca a pikachu si el
turno es igual a cero le toca a gigli
por esta batalla está arreglada turno es
igual a 1 vamos a tener esa variable
turno es igual a 1 porque piqué yo
arranca inicia nuestra baja de pokemon
las batallas porque mono ocurren en
ciclos primero le toca uno y si siguen
con vida le toca otro y si siguen con
vida le toca una vez más al primero
ciclo ciclo de ataque hasta que alguien
pierda realmente nadie muere en el mundo
pokemon pero por alguna razón la
medicina es gratis lo que vamos a crear
entonces es un ciclo los ciclos en la
programación son instrucciones
repetitivas que ocurren mientras una
condición sea verdadera esto qué
significa mientras la vida de pikachu
sea mayor que 0 es decir está vivo y la
vida de gigli posee mayor que 0 entramos
al ciclo de combate que es lo primero
que tenemos que verificar recuerden que
programar es como hablarle a alguien que
no tiene conocimiento de nada tienen que
decirle todo pasito a paso tenemos que
evaluar el turno de quién es cuánto vale
turno 1 entonces a quién le toca a
pikachu lo primero que hacemos en el
ciclo es si turno es igual a 1 turno de
pikachu el turno de pikachu se define
como que la vida de gigli x es igual a
la vida de gigli por menos el ataque de
pikachu gigli
vida es igual a gigli form punto vida
menos pikachu punto ataque porque no
puedo decir simplemente gigli por punto
vida menos pikachu punto ataque
porque es álgebra entonces tengo que
asignarle a la variable se acuerdan de
las variables tengo que asignarle a la
vida de gigli por su misma vida
- el ataque que le estoy quitando
[Música]
ahora gigli pues tiene menos 55 y su
vida vale 45 que es lo último que me
toca hacer antes de terminar el ciclo
cambiar el turno entonces ahora turno es
igual a 0 para que cuando haga el ciclo
le toque a gigli po termina el ciclo y
volvemos al principio mientras la vida
de picasso sea mayor que 0 lo es y la
biopsia mayor que 0 todavía lo es
entramos al ciclo un turno es igual a 1
nocturno es igual a 0 vamos al turno de
gigli por y el turno gigli prof es tan
fácil como decir pikachu punto vida es
igual a pikachu punto vida menos gigli
por punto ataque con ahora pikachu tiene
65 de vida porque gigli por flota con 45
les dije que esta partida estaba reglada
que nos falta hacer cambiar el turno
entonces el turno ahora es igual a 1
ciclo volvemos al inicio mientras la
vida de pikachu va ya se lo saben ahora
le toca pikachu hitler punto vida que
vale 45 es igual a gigli punto vida 45 -
piqué su punto ataque 55
ahora gigli por vida tiene menos diez
clips está muerto pero si glifos no lo
sabe todavía porque no hemos salido del
ciclo filippov está ahí en menos 10 y
recuerden la programación corre a la
velocidad de la luz así que a medida que
nosotros hacemos esto lentamente y paso
por paso nuestro computador ya lo hizo
hace millones de mini segundos
nanosegundos microsegundos muy rápido
todavía creemos que llegue porque está
vivo así que le va a tocar una vez más
ágil y por fin del ciclo vamos a la
condición mientras pikachu punto vida
sea mayor que 0 todavía es mayor que 0
no se acuerdan y gigli por vida sea
mayor que 0 menos 10 no entonces la
ecuación es falsa gigli por está muerto
y picacho está vivo
gigli pues tiene una vida menor que cero
por ende la condición no se cumple
salimos del ciclo y vamos a la parte de
abajo del algoritmo en la parte de bajo
el algoritmo
tenemos una condición las condiciones
tenemos que saber quién murió fue
pikachu como
picasso vida es menor o igual a cero y
noten lo que hice acá no todo es menor o
mayor puedo hacer igual mayor o igual
menor o igual es pikachu punto vida
menor o igual a cero no picacho punto y
está perfecto pikachu punto vida no es
menor que cero y como solamente hay dos
pokemons y la ecuación del ciclo nos
obligaba a salir cuando uno los dos
estuviera muerto
no necesitamos directamente preguntar si
gigli pov es menor que cero ya es obvio
que lo es no hay otra condición
así que mostramos la animación de qué
pikachu ganó estos son todas las bases
para aprender a programar desde el
inicio hoy aprendiste variables
condiciones ciclos y si estás en este
momento en el curso de programación
básica de mejorándola en platz y nuestra
plataforma educación online vas a
encontrar todos los archivos en
javascript que es código de programación
de verdad para ver cómo esto funciona en
el mundo real que paso a paso te va a
estar mostrando qué vas a hacer esto es
solo la introducción esto es solamente
un vídeo pequeñito de un curso entero
con clases en vivo de cómo aprender a
programar desde cero el curso entero es
completamente gratis
mejorando la programación
[Música]
Weitere ähnliche Videos ansehen
Curso Python #04 - Primeiros comandos em Python3
Introduction to C++ | Lecture 1 | C++ and DSA Foundation Course
Basic Syntax Of A C Program: C Tutorial In Hindi #5
Object-Oriented programming Course Intro
1.3: Basics of drawing - p5.js Tutorial
41. OCR A Level (H046-H446) SLR8 - 1.2 Introduction to programming part 2 variables & constants
5.0 / 5 (0 votes)