Hi! If you're reading this, you're probably just getting started in the fascinating field of computer science and programming.
You will discover what is in this article:
In the developer community, it is customary to write this programme while you are first learning to code.
Enjoy this time since it will undoubtedly be recalled in the months and years to come as you think back on your first steps.
Two ways can be followed for this
A) Through Console
B) Through Python File
Let us check both the ways one by one
A) “HELLO WORLD” through Python Shell:
Step 1: Start IDLE
We will work with IDLE (Python's Integrated Development and Learning Environment) throughout this tutorial. IDLE is pre-loaded when Python is installed. You will write and execute your Python code here. The screen below will appear right away. The Python shell is what it is called (interactive interpreter). It's an interactive window where you may type lines of code or entire blocks of code and have them execute right away to see the results.
You'll notice that the text size is reduced by default. Options > Configure IDLE is where you may change this.
Step 2: Write a Message
By adding the necessary line of code, you must inform the computer that you wish to display a certain message.
Python's print() function is used to accomplish the following:
Try writing your message within the parentheses and double quotes like below:
Double quotation marks are required around the phrase "Hello, World!" because it is shown as a string, a data type that your code uses to represent strings of characters (for example, text).
Step 3: Output
Once you type the above line of code in the Python shell and hit Enter key, you will see the following output:
When you add the final quote mark, you'll see that the message within print() turns green.
This happens as a result of the fact that IDLE gives various colours to the various sorts of code components that you might utilise (notice that print is displayed in purple).
Great! You've just created your first Python "Hello, World!" programme.
Let's look at how to build a Python file so that you may store it and execute it at a later time (or simply keep it as a lovely reminder of your first Python programme!).
B) “HELLO WORLD” through a Python File:
Step 1: Create a File
New File is Displayed
Step 2: Write the Code
Step 3: Save the file
By selecting File > Save or by pressing Ctrl + S on the keyboard, you may save the new file. You will need to give your file a name and decide where to save it.
Step 4: Run the Program
Now you can run your file by clicking on Run > Run Module:
A new window will be opened and you should see the output of your program in blue:
Your application is now securely housed in a Python file, ready to use whenever you need it