Output
print function
The print function prints output to the console.
print("Hello World!")
$ python hello.py
Hello World!
Reference: https://docs.python.org/3/library/functions.html#print
String Concatenation and Formatting
String concatenation is the operation of joining character strings. In Python, there are several ways to concatenation strings.
Comma
print("hello","world")
String Concatenation
print("hello" + " " + "world")
String Interpolation
print("{0} {1}".format("hello","world"))
Format Literals
Python 3.6 introduced format literals, with a more elegant syntax (less redundancy).
greeting = "hello"
who = "humans"
print(f"{greeting} {who}")
Last updated
Was this helpful?