Content · Programming · Python

PyCharm Free Edition: Write and Run Your First Python Script

Writing a first script in PyCharm means creating a .py file, entering Python statements, and running it with the configured interpreter. Learn the essential ideas and try a practical example.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

Writing a first script in PyCharm means creating a .py file, entering Python statements, and running it with the configured interpreter.

Understanding the Concept


In the Project panel, right-click the project folder and choose New > Python File. Name the file greeting.py. Enter the sample exactly, save it, and use the green Run action or the context menu Run greeting. PyCharm displays output in the Run tool window. A successful run normally ends with exit code 0, which means the interpreter process completed without an unhandled error.

When and Why You Would Use This


A Python file may execute top to bottom without displaying anything unless you call print() or otherwise produce output. In the example we use a variable so you can edit the message and immediately observe the change.

Practical Example


learner_name = "Alex"
print("Welcome to Python,", learner_name)

Understanding the Example


The program displays Welcome to Python, Alex. Change the name, run it again, and confirm that the Run window shows the new value. The first assignment stores text; the print call outputs it.

Example Output


Welcome to Python, Alex

Try It Yourself


Add a second print statement with a goal for this course. Verify both lines appear in order.

Common Beginner Mistakes


  • Creating a plain text file instead of a Python file with the .py extension.
  • Running a different file because an older run configuration is selected.
  • Editing the code but reading output from an earlier run. Rerun after changes.

Key Takeaways


  • Create a Python source file inside the project folder.
  • Use Run to execute it with the selected interpreter.
  • Read the output and exit status in PyCharm’s Run window.
Share this resourceSend this page to someone who may find it useful.