Home » Python Tutorial » Python Hello World – Writing your first python program

Python Hello World – Writing your first python program


Reading Time - 4 mins

Prerequisites

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() function

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

Create a new notepad file and type the below statement and save it as “hello.py”. If you are new to python, make sure to save the file type as “.py”, which indicates that the file is a python file. Write Hello World to write Python Hello World program.

print("Hello, World!")

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

python hello world

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.
READ  Jupyter Notebook

Conclusion

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.

Array Interview Questions
Graph Interview Questions
LinkedList Interview Questions
String Interview Questions
Tree Interview Questions