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
sepandendparameters
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
# 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
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)