03 DataAndVariables
03 DataAndVariables
uppercase letters A, B, C, …
lowercase letters a, , , …
punctuation period, semi- olon, …
digits 0, , , …
special symbols &, |, \, …
control characters carriage return, tab, ...
Variable Declaration
• A variable is a name for a location in memory
• A variable must be declared by specifying its name and
its initial value
name = "Bob" .
body_temp = 98.6 .
light_on = False .
• This indicates that the value should not be changed after it is first
declared
• Some programming languages will actually forbit you to change
the value of a constant
Constants
• Constants are useful for three important reasons
• First, they give meaning to otherwise unclear literal values
➢ For example, NUM_STATES is more meaningful than the literal 50
• Third, they formally show that a value should not change, avoiding
inadvertent errors by other programmers
Value Assignment
• An assignment statement gives the variable an actual value in
memory
• The equals sign provides this function
total = 55
• i=7
• j = -8.7
• k=9
• c = “Hello World"
• is_it_on = True