Last active
September 22, 2016 14:06
-
-
Save IanMcT/e47b2fd2602ac78ece99659cfffd8971 to your computer and use it in GitHub Desktop.
Demonstrates variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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