Last active
August 29, 2015 14:27
-
-
Save harfordt/947718e46f1e1a752c8b to your computer and use it in GitHub Desktop.
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
name = "Rosa" | |
age = 14 | |
# example 1 - passing values to print() and letting it do the work | |
print(name, "is", age, "years old.") | |
# example 2 - print() puts a space between the parameters passed to it | |
print(name, "is aged", age, ".") | |
# example 3 - concatenate the strings, but you need to introduce spaces and cast ints etc as strings | |
print(name + " is aged " + str(age) + ".") | |
# example 4 - use .format() | |
print("{} is aged {}.".format(name, age)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment