Η συνάρτηση print() του Python

Παράδειγμα

Εκτυπώστε το μήνυμα στην οθόνη:

print(\"Hello World\")

Εκτέλεση Παραδείγματος

Definition and Usage

The print() function prints the specified message to the screen or other standard output devices.

The message can be a string or any other object, which will be converted to a string before being written to the screen.

Syntax

print(object(s), separator=separator, end=end, file=file, flush=flush)

Parameter Value

Parameter Description
object(s) Any object, and any number. The object is converted to a string before printing.
sep='separator' Optional. Specifies how objects are separated if there are multiple objects. The default value is ' '.
end='end' Optional. Optional. Specifies the content to be printed at the end. The default value is '\n' (newline).
file Optional. Object with write methods. The default is sys.stdout.
flush Οptional. Boolean value, specifies whether the output is refreshed (True) or buffered (False). The default is False.

Περισσότερα παραδείγματα

Παράδειγμα

Εκτύπωση πολλαπλών αντικειμένων:

print("Hello", "how are you?")

Εκτέλεση Παραδείγματος

Παράδειγμα

Εκτύπωση τάξης:

x = ("apple", "banana", "cherry")
print(x)

Εκτέλεση Παραδείγματος

Παράδειγμα

Εκτύπωση δύο μηνυμάτων και καθορισμός διαχωριστικού:

print("Hello", "how are you?", sep=" ---")

Εκτέλεση Παραδείγματος