Print Hello World Python Program

By | September 1, 2015

Print Hello World Python Program in Linux Ubuntu

Here, we have listed How To Print Hello World Python Program in Linux Ubuntu 14.04 using gEdit as Code Editor and Ubuntu Terminal.

Method 1: Python Program To Print Hello World in Ubuntu

Syntax:

print(” String of Character ” + List of Variables)

n is an Escape Sequence Character that tells the Python Interpreter to Insert a New Line.

Description

  • The cd Desktop command is the Change Directory command which helps to change your Current Directory to Desktop. It helps to get access to or manage the Desktop using Ubuntu Terminal.
  • The python HelloWorld.py command interprets the Source Code File using the Python Compiler available by default in Ubuntu. It, thereby executes the Python Program.
  • The print() method is available in the Python Library.
  • print() method takes in Two parameters that include: String of Characters and List of Variables (Optional).

Method 2: Print Hello World Python Program using Strings in Linux Ubuntu

Description

  • This program has a String Variable a which has a Hard Coded value stored in it i.e., CodingAlpha. We use this variable in the print() method’s parameter.
  • a = “CodingAlpha” :This statement declares a Variable a and defines it with a String value CodingAlpha.
  • print(“nHello World” + a) :This statement uses both the parameters . The First parameter prints just Hello World and then we include the + symbol which also means Concatenation in Python. So, in the above statement we have concatenated the Hello World String with the value of the String variable a. Therefore, it Print Hello World Python Program in Linux.
  • Note: It isn’t mandatory to end a Python statement with a Semi-Colon.

n is an Escape Sequence Character that tells the Python Interpreter to Insert a New Line.

 

Steps To Execute Python Programs in Linux Ubuntu

  • Create a Text File (using gEdit) named HelloWorld.py on Linux Ubuntu Desktop.
  • Paste the above code into the Text file and Save it with a .py extension.
  • Open Ubuntu Terminal by pressing Ctrl+Alt+T.
  • Type: cd Desktop and Hit Enter.
  • Type: python HelloWorld.py and Hit Enter.
  • Now, you would be able to see the Output as Hello World on the Terminal.

Output

Print Hello World Python Program in Linux Ubuntu

How To Run Hello World Python Program in Linux Ubuntu Video Tutorial

 

If you have any doubt about this Hello World Program in Python Language, mention in the Comment Section.

Let's Discuss