To print to the console, use the print() command. You can print any data type, but if it is not a string, Python must convert it to a string first. This command will automatically create a new line afterwards.
print("Hello World")
print(0)
print(7.8)
print(False)
To print without a new line, use this variation on the print command: print("text", end = "")
To insert certain characters in your string, you can't just place them inside of your string. We use the backslash character, \, to show Python we're doing something unusual in our string. (Note, this is the backslash \, not the forward slash /.)
Here are the most commonly used escape characters:
/n (newline)
/t (tab)
/" (")
/' (')
// (/)
You can use single or double quotes to contain string characters. (Single quotes are conventional for Python, but I'll mostly be using double quotes to stay consistent with Java programming.)
If you're using single quotes you'll need \' to represent the ' within the string, other wise Python thinks you're trying to close the string. Likewise, if you use double quotes, you'll need \" to represent " within the string.
For example, if you wanted to represent My sister said, "That's not fair!" as a string, you could do it with either of these:
"My sister said, \"That's not fair!\""
'My sister said "That\'s not fair!"'
Every text symbol must be interpreted by the computer as a number. Originally they were given a value with the ASCII system, but now we use a global system called Unicode.
To print a character using its Unicode value, just use \u#### where #### is the unicode value.
For example:
\u00A9 is ©
\u03C0 is π
\u00B1 is ±