Hello World: Create your First Python Program

โšก Smart Summary

Hello World is the traditional first Python program. The steps below show how to create and run it in the PyCharm IDE and from the command line, then explain the print() function and the common errors beginners encounter.

  • ๐Ÿ–ฅ๏ธ Create Project: Open PyCharm, create a new project, and name it something meaningful.
  • ๐Ÿ“„ Add File: Create a new Python file, for example HelloWorld.py.
  • โŒจ๏ธ Write Code: Type print(“Hello World”) into the editor.
  • โ–ถ๏ธ Run It: Use the Run menu, and the output appears at the bottom of the screen.
  • ๐Ÿ’ป No IDE Needed: You can also run the file from the command prompt or an online editor.
  • โš ๏ธ Watch For: Python is case-sensitive, so use print, not Print.

Create your First Python Program

In the last tutorial, we completed our Python installation and setup. It is time to create your first program.

Creating First Program

Step 1) Open the PyCharm Editor. You can see the introductory screen for PyCharm. To create a new project, click on “Create New Project”.

Creating First Python Program

Step 2) You will need to select a location.

  1. You can select the location where you want the project to be created. If you do not want to change the location, then keep it as it is, but at least change the name from “untitled” to something more meaningful, like “FirstProject”.
  2. PyCharm should have found the Python interpreter you installed earlier.
  3. Next, click the “Create” Button.

Creating First Python Program

Step 3) Now go up to the “File” menu and select “New”. Next, select “Python File”.

Creating First Python Program

Step 4) A new pop-up will appear. Now type the name of the file you want (here we give “HelloWorld”) and hit “OK”.

Creating First Python Program

Step 5) Now type a simple program – print(‘Hello World!’).

Creating First Python Program

Step 6) Now go up to the “Run” menu and select “Run” to run your program.

Creating First Python Program

Step 7) You can see the output of your program at the bottom of the screen.

Creating First Python Program

Step 8) Do not worry if you do not have the PyCharm Editor installed, you can still run the code from the command prompt. Enter the correct path of a file in the command prompt to run the program.

Creating First Python Program

The output of the code would be:

Creating First Python Program

Step 9) If you are still not able to run the program, we have a Python Editor for you. Please run the given code at the Python Online Editor.

print("Hello World")  

Understanding the Hello World Program

The Hello World program is only one line, but it introduces the most important building block in Python: the print() function. The print() function displays whatever you place inside its parentheses on the screen.

In the example below, the text “Hello World” is a string. A string is a sequence of characters wrapped in single or double quotes. Python treats ‘Hello World’ and “Hello World” the same way, so you can use either style.

message = "Hello World"
print(message)

A few points make Python beginner-friendly. You do not need to declare a data type for the variable, there is no semicolon at the end of the line, and the program runs immediately without a separate compile step. Python is also case-sensitive, so print must be written in lowercase.

Common Errors When Writing Your First Python Program

Beginners often hit a few small errors when running their first program. Here are the most common ones and how to fix them:

  • NameError / capitalization: Writing Print instead of print. Python is case-sensitive, so the function name must be lowercase.
  • SyntaxError: Forgetting a parenthesis or a closing quote, such as print(“Hello World). Always match your brackets and quotes.
  • Smart quotes: Copying code with curly quotes (“”) instead of straight quotes (“”). Retype the quotes inside a code editor.
  • IndentationError: Adding an unexpected space or tab before print. The first line of code should start at the very left.
  • File not found: Running the wrong path in the command prompt. Save the file first and use its exact location.

FAQs

No. Python is an interpreted language, so you do not compile it separately. When you run the file, the Python interpreter reads and executes the code line by line, which is why your Hello World program runs instantly.

Python is case-sensitive. The built-in function is named print in all lowercase, so writing Print or PRINT is treated as an unknown name and raises a NameError. Always type print exactly in lowercase.

Yes. Online Python editors let you write and run code directly in a browser without any installation. They are great for quick practice, though installing Python locally is better for building and saving real projects.

Yes. AI assistants can generate a Hello World program and explain each line. However, typing and running it yourself helps you learn faster, so use AI to check your work and clarify errors rather than only copying output.

AI can explain concepts in simple terms, suggest practice exercises, and debug your errors with plain-language hints. Used alongside hands-on coding, it acts like a patient tutor that answers questions instantly and keeps beginners motivated.

Summarize this post with: