1.1 Output – Printing to the screen
Use the print() function to print to the the screen. The following code snippet will print Welcome to programming in Python to the screen.
print("Welcome to programming in Python")
Here are some important points to note when you use the print() function.
- In Python text is case sensitive therefore print, Print, prinT are all different, you must use print() for output.
- String literals – text to be displayed on the screen must be enclosed in quotation marks, this quotation mark can be single, double and triple (special case – dealt with later in the course)
- The following are all legal print() statements in Python.
print("This is a legal statement") print('This is also legal, using single quotation mark') print('''This is also legal, but a special case - called docstring ''')