What Is a Variable?
Variables in programming are abstract local storages for values. In the previous section, you calculated a 5-year revenue. What if we need this exact same number in the future? Recalculating seems a bit irrational.
To refer to a specific value in the future, we need to use a particular name for the variable. Use the equality sign =
for assigning value to a variable. For example, you can assign the value 2022
to the variable year
, and then output it or perform any arithmetic operation using its name.
123456# Create a variable year = 2020 # Output its value print(year) # Perform an addition print(year + 10)
This is the ninth chapter of the course. Create a variable chapter
with a value of 9
.
Obrigado pelo seu feedback!
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Pergunte-me perguntas sobre este assunto
Resumir este capítulo
Mostrar exemplos do mundo real
Awesome!
Completion rate improved to 4
What Is a Variable?
Deslize para mostrar o menu
Variables in programming are abstract local storages for values. In the previous section, you calculated a 5-year revenue. What if we need this exact same number in the future? Recalculating seems a bit irrational.
To refer to a specific value in the future, we need to use a particular name for the variable. Use the equality sign =
for assigning value to a variable. For example, you can assign the value 2022
to the variable year
, and then output it or perform any arithmetic operation using its name.
123456# Create a variable year = 2020 # Output its value print(year) # Perform an addition print(year + 10)
This is the ninth chapter of the course. Create a variable chapter
with a value of 9
.
Obrigado pelo seu feedback!