Operating With Variables
What can we do with the assigned variable? After creating variables with a specific value, you can access this value in the future by using the variable's name and performing available operations.
For example, we can use the variable chapter
that was created several chapters ago. We can add 4
to find out the number of the current chapter. Suppose you want to use this value in the future. In that case, you need to create or reassign a new value to an existing variable.
123456# Creating a variable chapter = 9 # Reassign variable chapter = chapter + 4 # Output modified value print(chapter)
Suppose you have a variable level
representing the current player's level. Suppose the player reaches the next level. You need to add 1
to the level
variable and reassign the value.
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Pregunte me preguntas sobre este tema
Resumir este capítulo
Mostrar ejemplos del mundo real
Awesome!
Completion rate improved to 4
Operating With Variables
Desliza para mostrar el menú
What can we do with the assigned variable? After creating variables with a specific value, you can access this value in the future by using the variable's name and performing available operations.
For example, we can use the variable chapter
that was created several chapters ago. We can add 4
to find out the number of the current chapter. Suppose you want to use this value in the future. In that case, you need to create or reassign a new value to an existing variable.
123456# Creating a variable chapter = 9 # Reassign variable chapter = chapter + 4 # Output modified value print(chapter)
Suppose you have a variable level
representing the current player's level. Suppose the player reaches the next level. You need to add 1
to the level
variable and reassign the value.
¡Gracias por tus comentarios!