Python Hello World – Sample Program in Python

How to Write a Hello Word Program in Python

In this tutorial, you'll learn how to write and print a hello world program in Python. This tutorial also provides an example and hello world python script.

Python is a simple programming language, so even if you are a beginner or don't have knowledge of programming before, you can learn it quickly.

To write a hello world program in Python, you create a file with the ".py" extension and then use the print() function to print "Hello, World" to the screen.

Let's take a look at examples:


Example 1: Using print() Function

The following sample code prints out "Hello, Word" to the screen:

#simple python program
#hello world
#print "Hello, World!"
print("Hello, World!")

As you can see, you need to write only one line to print out "Hello, World!". Python is a simple programming language.

Example 2: Using an Variable and print() Function

The following example illustrates an example of using a variable to store "Hello, World!" and then prints the variable value to the screen:

#simple python program using variable

my_variable = "Hello, World!"

As you can see, we assign "Hello, World!" to a variable named my_variable and then print the variable to screen.

In this tutorial, you've learned how to write a simple hello world program and print out "Hello, World!" in Python.

See also:
Python return Statement with Examples
Python List Methods and Functions with Examples
Python abs() – Absolute Value in Python
Python Factorial – Find the Factorial of a Number
Python min() – Find the Smallest Value in Python

Leave a Comment