First Python Program
print("Hello, World!")
Welcome to Python 3.12
How does this code work ?
print(): This is a built-in function of Python. Its job is to display the text typed in
it as output on the computer screen.
Double Quotes ("..."): Python treats anything written inside quotes as a string, i.e.,
plain text, and prints it as is on the screen.
Method A: Using IDLE or VS Code (by creating a file)
1. Open your code editor (such as Notepad, VS Code, or IDLE).
2. Type the line above: print("Hello, World!")
3. Save this file as hello.py (remember, Python file extensions should always be .py).
4. Go to your terminal or command prompt (CMD) and go to the folder containing this file and
type this command: python hello.py
5. The output will appear on the screen: Hello, World!
Method B: Using Interactive Mode (without creating a file)
1. Open your computer's Terminal (Mac/Linux) or Command Prompt (Windows).
2. Simply type python and press Enter. This will open the Python interactive shell (where >>>
appears).
3. Now simply type: print("Hello, World!") and press Enter. You will immediately get the output
below.