A Python program built one function at a time/guide
Jump to navigation
Jump to search
Python is a programming language that's commonly used. A function in this context, is an instruction to the computer, so basically any form of Python command. Remember to format the entire program in code text (like this). Read a guide to Python if you can't understand which functions to place.
Tips[edit | edit source]
- If you want to print something on the next line, append the last print command before the final quote with “\n”, which adds a newline character (Unicode: U+000A)
- If you want the program to make a sound, type in the keyword “\a” when printing, which adds a BEL character (Unicode: U+0007). In programming environments that do not have audible BEL characters, this may not work.
- If you want a non-ASCII character when printing, type in the keyword “\u” and append it with that character's Unicode point before continuing or finishing the function.
- If you want to run the program, the most convenient way to do so is TIO.run, a family of online interpreters for mainstream and esoteric programming languages, except when it uses modules, in which you'll need to use PyCharm instead in case it has custom Python modules like
pygame. - Another exception to the first rule is when you are entering a function from a module and import it so it doesn't cause a syntax error, for example, outputting a math function and entering
import mathat the same time. - All instances of a literal backslash must be prepended with another backslash. Other escape characters include:
- \" (quotation mark)
- \' (apostrophe)
- \\ (backslash)
- \b (backspace; deletes the previous character)
- \t (horizontal tab)
- \r (carriage return; move the cursor to the beginning of the line)
- \v (vertical tab; moves the cursor up)
- \0 (null; a string ends when this character is used)
- \f (form feed; moves the cursor to the next page)