Before starting with this tutorial, please make sure you have python 3 installed as well as a local programming environment set up on your computer. If you don’t have one, please check the previous tutorial on Install Python. In this article, we will help you to write your first program on Python Hello World.
print() is a built-in function that tells the computer to perform an action. We know it is a function because it has parentheses(in python a function is called always with parentheses). print() tells Python to display the output whatever we put in the parentheses. By default, the output will be displayed on the current terminal window.
Some functions, like the print() function, are built-in functions included in Python by default. These built-in functions are always available for us to use in programs that we create. Let’s see a simple print() function in this topic.
Creating a .py file
Running from Command Prompt
- Open Command prompt
- Navigate to the folder where you saved his “hello.py” file.
- You can run your program by giving “python(space)Name of your python file”.Since we saved our files as hello.py, we need to give python hello.py
Printing in IDL
- You can also open python from your command prompt simply by typing python. To exit, give exit()
- Else you can open your python idle
- Give print(“Hello World”) and then give enter.
Congratulations! You have written the “Hello, World!” program in Python 3. From here, you can continue to work with the
print() function by writing your own strings to display, and can also create new program files.
We will see more examples of print in the upcoming tutorials and learn more about the syntax and data types.