Python Оператор Print(): як друкувати з прикладами
⚡ Розумний підсумок
Python print() function displays a message or object on the screen after converting it to a string. The examples below show how to print strings, blank lines, and multiple items, and how to control line endings.

Python функція print ()
Функція print() в Python використовується для друку вказаного повідомлення на екрані. Команда друку в Python друкує рядки або об'єкти, які перетворюються на рядок під час друку на екрані.
Синтаксис:
print(object(s))
Як надрукувати простий рядок Python?
Частіше не потрібно Надрукувати рядки у вашій конструкції кодування.
Ось як надрукувати виписку Python 3:
Приклад: 1
Щоб роздрукувати вітальне повідомлення Guru99, використовуйте Python надрукувати заяву наступним чином:
print ("Welcome to Guru99")
вихід:
Ласкаво просимо до клініки Guru99
In Python 2, такий самий приклад буде виглядати
print "Welcome to Guru99"
Приклад 2:
Якщо ви хочете надрукувати назву п’яти країн, ви можете написати:
print("USA")
print("Canada")
print("Germany")
print("France")
print("Japan")
вихід:
USA Canada Germany France Japan
Як друкувати порожні рядки
Іноді вам потрібно надрукувати один порожній рядок у вашому Python програма. Нижче наведено приклад виконання цього завдання Python формат друку.
приклад:
Виведемо 8 порожніх рядків. Ви можете ввести:
print (8 * "\n")
або:
print ("\n\n\n\n\n\n\n\n\n")
Ось код
print ("Welcome to Guru99")
print (8 * "\n")
print ("Welcome to Guru99")
Вихід
Welcome to Guru99 Welcome to Guru99
Команда завершення друку
By default, the print function in Python ends with a newline. This function comes with a parameter called ‘end’. The default value of this parameter is ‘\n’, i.e., the new line character. You can end a print statement with any character or string using this parameter. This is available only in Python 3 +.
Приклад 1:
print("Welcome to", end=' ') print("Guru99", end='!')
вихід:
Ласкаво просимо до клініки Guru99!
Приклад 2:
# ends the output with '@' print("Python", end='@')
вихід:
Python@
