Hello, World!
print("Hello, World!")
Write Python. Understand every error.
Python basics · topic 2 of 25
The traditional first program in any language shows the words Hello, World! on the screen. In Python it is one line.
print("Hello, World!")
Text inside quotes is called a string. You can use double quotes "..." or single quotes '...', as long as both ends match.
You can give print() several values separated by commas. Python prints them on one line with a space between each.
print("Marks:", 85, "out of", 100)
Two optional settings change how values are printed. sep sets what goes between values, and end sets what goes at the end instead of a new line. Inside a string, \n starts a new line.
print("text") shows text exactly as written inside the quotes.sep="-" changes the separator, end="" stops the new line.\n inside a string means "new line".print("text") shows text exactly as written inside the quotes.sep changes the separator and end changes what comes at the end of the line.\n inside a string starts a new line.print(hello) looks for a variable called hello. Read the NameError guide.print("hi". Read the SyntaxError guide.+, as in print("Age: " + 19). Use a comma or an f-string. Read the TypeError guide.
print("Hello, World!")
print("Marks:", 85, "out of", 100) print("Name:", "Riya", "Class:", 12)
print("2026", "09", "22", sep="-") print("a", "b", "c", sep="")
print("Loading", end="...") print("done")
print("Line one\nLine two\nLine three")
5 quick questions to check your understanding. Choose an answer for each, then press Check answers.
print("a", "b", "c")
Commas separate values, and print() puts one space between them.
print("2026", "09", "28", sep="-")
sep replaces the space between values.
print("Hi", end="!") print("Bye")
end="!" replaces the usual new line, so the next print continues on the same line.
print("one\ntwo")
\n inside a string starts a new line.
Text must be inside quotes, and print needs round brackets. Without quotes, Python looks for a variable called Python.