Skip to content

Instantly share code, notes, and snippets.

@IanMcT
Last active September 22, 2016 14:06
Show Gist options
  • Save IanMcT/e47b2fd2602ac78ece99659cfffd8971 to your computer and use it in GitHub Desktop.
Save IanMcT/e47b2fd2602ac78ece99659cfffd8971 to your computer and use it in GitHub Desktop.
Demonstrates variables
#I McTavish
#Sept 21, 2016
#Variables - demonstrate variables
#Declare an integer variable
my_age = 17
#output my_age
print(my_age)
#output type of data
print(type(my_age))
#do math
my_age_next_year = my_age+1
print(my_age_next_year,type(my_age_next_year))
#Declare an string variable
my_age_as_string = "17"
#output my_age
print(my_age_as_string)
#output type of data
print(type(my_age_as_string))
#do math
#following would generate an error
#my_age_next_year = my_age_as_string+1
#print(my_age_next_year,type(my_age_next_year))
#Declare a float variable
decimal_number = 1.0
print(decimal_number,type(decimal_number))
#Declare a Boolean variable
boolean_variable = True
print(boolean_variable,type(boolean_variable))
boolean_variable = False
print(boolean_variable,type(boolean_variable))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment