{"id":100,"date":"2020-10-03T01:41:43","date_gmt":"2020-10-03T01:41:43","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=100"},"modified":"2025-03-25T09:22:51","modified_gmt":"2025-03-25T09:22:51","slug":"python-hello-world","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/getting-started\/python-hello-world\/","title":{"rendered":"Python Hello World"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to develop the first program in Python called &#8220;Hello, World!&#8221;.&nbsp;<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>If you can write &#8220;hello world&#8221; you can change the world.<\/p>\n<cite><strong>Raghu Venkatesh<\/strong><\/cite><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id='creating-a-new-python-project'>Creating a new Python project <a href=\"#creating-a-new-python-project\" class=\"anchor\" id=\"creating-a-new-python-project\" title=\"Anchor for Creating a new Python project\">#<\/a><\/h2>\n\n\n\n<p>First, create a new directory called <code>helloworld<\/code> anywhere in your system, e.g., C:\\ drive.<\/p>\n\n\n\n<p>Second, launch the VS Code and open the <code>helloworld<\/code> directory.<\/p>\n\n\n\n<p>Third, create a new <code>app.py<\/code> file, enter the following code, and save it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(<span class=\"hljs-string\">'Hello, World!'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>print()<\/code> is a built-in <a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-functions\/\">function<\/a> that displays a message on the screen. In this example, it&#8217;ll show the message <code>'Hello, World!'<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='what-is-a-function'>What is a function <a href=\"#what-is-a-function\" class=\"anchor\" id=\"what-is-a-function\" title=\"Anchor for What is a function\">#<\/a><\/h2>\n\n\n\n<p>When you sum two numbers, that&#8217;s a <a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-functions\/\">function<\/a>. And when you multiply two numbers, that&#8217;s also a function. Generally, a function takes your inputs, applies some rules, and returns a result.<\/p>\n\n\n\n<p>In the above example, the <code>print()<\/code> is a function. It accepts a string and shows it on the screen.<\/p>\n\n\n\n<p>Python has many built-in functions like the <code>print()<\/code> function you can use out of the box in your program.<\/p>\n\n\n\n<p>In addition, Python allows you to <a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-functions\/\">define your functions<\/a>, which you&#8217;ll learn how to do it later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='executing-the-python-hello-world-program'>Executing the Python Hello World program <a href=\"#executing-the-python-hello-world-program\" class=\"anchor\" id=\"executing-the-python-hello-world-program\" title=\"Anchor for Executing the Python Hello World program\">#<\/a><\/h2>\n\n\n\n<p>To execute the <code>app.py<\/code> file, you first launch the Command Prompt on Windows or Terminal on macOS or Linux.<\/p>\n\n\n\n<p>Then, navigate to the <code>helloworld<\/code> directory.<\/p>\n\n\n\n<p>After that, type the following command to execute the <code>app.py<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">python app.py<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you use macOS or Linux, you use <code>python3<\/code> command instead:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">python3<\/span> <span class=\"hljs-selector-tag\">app<\/span><span class=\"hljs-selector-class\">.py<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If everything is fine, you&#8217;ll see the following message on the screen:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Hello, World!<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you use VS Code, you can also launch the Terminal within the VS code by:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Accessing the menu <strong>Terminal &gt; New Terminal<\/strong><\/li>\n\n\n\n<li>Or using the keyboard shortcut <code>Ctrl+Shift+`<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Typically, the backtick key (<code>`<\/code>) located under the <code>Esc<\/code> key on the keyboard.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='python-idle'>Python IDLE <a href=\"#python-idle\" class=\"anchor\" id=\"python-idle\" title=\"Anchor for Python IDLE\">#<\/a><\/h2>\n\n\n\n<p>Python IDLE is the Python Integration\u00a0Development Environment (IDE) that comes with the Python distribution by default.<\/p>\n\n\n\n<p>The Python IDLE is also known as an interactive interpreter. It has many features, such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Code editing with syntax highlighting<\/li>\n\n\n\n<li>Smart indenting<\/li>\n\n\n\n<li>And auto-completion<\/li>\n<\/ul>\n\n\n\n<p>In short, the Python IDLE helps you experiment with Python quickly in a trial-and-error manner.<\/p>\n\n\n\n<p>The following shows you step by step how to launch the Python IDLE and use it to execute the Python code:<\/p>\n\n\n\n<p>A new Python Shell window will display as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"535\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell.png\" alt=\"IDLE Shell\" class=\"wp-image-6921\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell.png 531w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell-298x300.png 298w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell-150x150.png 150w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/figure>\n\n\n\n<p>Now, you can enter the Python code after the cursor <code>>>><\/code> and press <code>Enter<\/code> to execute it. For example, you can type the code <code>print('Hello, World!')<\/code> and press <code>Enter<\/code>, you&#8217;ll see the message <code>Hello, World!<\/code> immediately on the screen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"356\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell-hello-world.png\" alt=\"IDLE Shell - hello world\" class=\"wp-image-6922\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell-hello-world.png 531w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/03\/IDLE-Shell-hello-world-300x201.png 300w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the<code> python app.py<\/code> command from the Command Prompt on Windows or Terminal on macOS or Linux to execute the <code>app.py<\/code> file.<\/li>\n\n\n\n<li>Use the <code>print()<\/code> function to show a message on the screen.<\/li>\n\n\n\n<li>Use the Python IDLE to type Python code and execute it immediately.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"100\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/getting-started\/python-hello-world\/\"\n\t\t\t\tdata-post-title=\"Python Hello World\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"100\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/getting-started\/python-hello-world\/\"\n\t\t\t\tdata-post-title=\"Python Hello World\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you&#8217;ll learn how to develop the first program in Python called &#8220;Hello, World!&#8221;.&nbsp; If you can write &#8220;hello world&#8221; you can change the world. Raghu Venkatesh Creating a new Python project # First, create a new directory called helloworld anywhere in your system, e.g., C:\\ drive. Second, launch the VS Code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":39,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-100","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/100\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/39"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}