Skip to content

Instantly share code, notes, and snippets.

@harfordt
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harfordt/947718e46f1e1a752c8b to your computer and use it in GitHub Desktop.
Save harfordt/947718e46f1e1a752c8b to your computer and use it in GitHub Desktop.
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