Variables

n = 17
 
# print out the value of the variable
print n
 
# variables can be assigned another value and type
n = "Hi Joy"
# variables will always inherit the last value and type it was assigned
print n
 
#make sure to keep track (and differentiate) your variable names
x = 17
pi = 3.14159
greeting = "Hi Joy"
 
print type(x)
print type(pi)
print type(greeting)
 
# A variable name contains letters and numbers and must begin with a letter.  
# By convention, a variable does not start with a capital letters.  
# Also, must avoid the default keywords that are already 'taken'
#Illegal variable names
#7x = 7*x
#print 7x
#pi~ = 3.14159
#print pi~
#def = "Hi Joy"
#print def
 
# A statement is an instruction that can be executed.  
# So far we've seen two kinds: print and assignment
# A script is just a sequence of statements
 
# statements can be combined with commas to print a single line
print "x is a", type(x), " and has a value of", x