Created
May 10, 2013 06:59
-
-
Save nuclearsandwich/5552845 to your computer and use it in GitHub Desktop.
Variables, strings, arithmetic, and concatenation in Python.
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
num1 = 5 | |
num2 = 7 | |
addition = num1 + num2 | |
subtraction = num2 - num1 | |
multiplication = num1 * num2 | |
division = num2 / num1 # rounds down for integer division | |
print(addition) # prints 12 | |
print(subtraction) # prints 2 | |
print(multiplication) # prints 35 | |
print(division) # prints 1 | |
string1 = "hello" | |
string2 = "world" | |
addition = string1 + string2 | |
print(addition) # prints "helloworld" (sticks strings together | |
subtraction = string1 - string2 # gives an error, subtraction/multiplication/division doesn't make sense for strings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment