Python commands Flashcards
Embed a variable in a string
f”some string {somevar}”
format an existing string
existing_string= “some string {}”. existing_string.format(variable OR “string”)
tell print to not end the line with a newline character and go to the next line.
print(var1 + var2, end = “ “)
print(var3 + var4)
print a string repeatedly 10 times (no loop)
print(“string” * 10)
print something on a new line
“string\nstring”
print “as many rows as you like”
print(“"”enter string
for as many rows as you like
“””)
Escape sequence: Backslash ()
\
Escape sequence: single quote
'
Escape sequence: double quote
"
Escape sequence: ASCII bell (BEL)
\a
Escape sequence: ASCII backspace (BS)
\b
Escape sequence: ASCII formfeed (FF) (format)
‘insert a page break’
\f
Escape sequence: ASCII linefeed (LF) (new line)
\n
Escape sequence: Character named name in the Unicode database (Unicode only)
\N{name}
Escape sequence: Carriage return (CR) (resets to left-most in a row and overwrites with the rest of the line)
\r