Variables

What are Variables?

  • Variables are containers for storing data in a program
  • They hold values that can change while the program runs

Why are Variables Needed?

  • Store Information: Variables allow programs to keep and use data, like names, numbers, or results of calculations
  • Make Programs Flexible: By changing the value of a variable, the program can adapt to different inputs or situations
  • Simplify Reuse: Variables let you use the same data multiple times without retyping it

Python Examples

String

 
name = "Alice"
print(name) 

Integer

age = 25
print(age)

Real / Float

 
pi = 3.14
print(pi) 

Reusing a Variable

message = "Bye"
print(message)
print(message, message)

Changing a Variable's Value

score = 10
score = 20
print(score)
Button TextButton Text[/vc_column_inner][/vc_row_inner]