beginner

Hello World

Write your first Python program and learn the print() function

The "Hello, World!" program is traditionally the first program that developers write when learning a new programming language. This simple exercise introduces you to Python's syntax and the fundamental concept of outputting text to the console.

📚 Concepts & Theory

The print() function is one of the most commonly used built-in functions in Python. It outputs text, variables, or expressions to the console (also called standard output or stdout).

Basic Syntax

print("Your text here")

Key Concepts

    • Strings: Text in Python must be enclosed in quotes (single '' or double "")
    • Function calls: Functions are called using parentheses ()
    • Statements: Each line of code that performs an action is a statement

The print() Function Features

    • Accepts multiple arguments separated by commas
    • Automatically adds a newline at the end
    • Can be customized with sep and end parameters

Examples

print("Hello")             # Basic output
print('Single quotes')     # Single quotes work too
print("Line 1", "Line 2")  # Multiple arguments
print("No newline", end="") # Suppress newline

Understanding print() is your first step toward debugging and creating interactive programs.

🎯 Your Challenge

Create a Python program that prints exactly "Hello, World!" to the console. Pay attention to the exact capitalization and punctuation.

📝 Starter Code

Python
# Write your code here
  • Use the print() function
  • Enclose your text in quotes (single or double)
  • Make sure to match the exact text: Hello, World!

Solution

Python
print("Hello, World!")

Explanation

This solution uses the print() function with a string argument. The string "Hello, World!" is enclosed in double quotes and passed to print(), which outputs it to the console.

⚠️ Common Mistakes to Avoid

  • Forgetting the parentheses: print Hello instead of print(Hello)
  • Missing quotes around the string
  • Using smart quotes from word processors
  • Incorrect capitalization (Python is case-sensitive)

❓ Frequently Asked Questions

The print() function is a built-in Python function that outputs text, variables, or expressions to the console. It is the primary way to display information to users and is essential for debugging programs.
Yes, text strings must be enclosed in either single quotes or double quotes. Python treats both the same way, but you must use matching pairs.
Hello World has been the traditional first program since Brian Kernighan used it in 1972. It demonstrates the minimal syntax needed to produce output, helping beginners verify their development environment works correctly.

🔗 Related Concepts