Getting Started

Python - IntroductionPython - Hello World ProgramPython - SyntaxPython - Data TypesPython - Variables

Operators

Python - Arithmetic OperatorsPython - Relational OperatorsPython - Logical OperatorsPython - Assignment OperatorsPython - Bitwise OperatorsPython - Membership OperatorsPython - Identity OperatorsPython - Increment and Decrement Operators

Conditions

Python - If Else statement

Loop

Python - While LoopPython - For Loop

Numbers

Python - NumbersPython - Number Conversion

Strings

Python - StringsPython - String OperatorsPython - String FormattingPython - String MethodsPython - String Format Method

List

Python - ListPython - List Methods

Tuple

Python - Tuple

Set

Python - SetPython - Set Methods

Dictionary

Python - DictionaryPython - Dictionary Methods

Functions

Python - FunctionsPython - Functions - Variable length argumentsPython - Lambda Function

Scope of Variables

Python - Scope of Variables

Modules

Python - ModulesPython - Math ModulePython - JSON ModulePython - datetime ModulePython - time Module

I/O

Python - Read input from keyboard

File

Python - File Handling

Exception Handling

Python - Exception Handling

OOP

Python - Classes and ObjectsPython - Class Constructor __init__ methodPython - Class Destructor __del__ methodPython - Built-in Class AttributesPython - InheritancePython - Method OverridingPython - Method Overloading

Package Management

Python - PIP

Python - MySQL

Python - MySQL - Getting StartedPython - MySQL - Insert dataPython - MySQL - Select dataPython - MySQL - Update dataPython - MySQL - Delete data

Python - CSV

Python - Read data from CSV filePython - Write data in CSV file

Python - Hello World Program

Python

python logo

In this tutorial we will write our first Hello World Python program.

Lets go ahead and write the "Hello World" program using text editor like Sublime Text and then we will use PyCharm IDE.

Feel free to use any other text editor of your choice.

Using text editor

Lets begin our journey by printing "Hello World" text using Python.

Create a new file by the name HelloWorld.py and then write the following code inside.

print("Hello World")

We don't have to put semicolon ; at the end of the line in Python like we do in other programming langauages like C and Java.

Now, open the Terminal (for Mac and Linux) and type the following command.

$ python HelloWorld.py

For Windows, assuming you have Python executable installed on your C:, run a similar command in the Command Prompt.

c:\pythonXX\python HelloWorld.py

Where, pythonXX is the Python version you have installed on your machine.

If there was no error then you will get to see the "Hello World" text on your screen.

python hello world program

Using PyCharm IDE

In the following example we will be using PyCharm Community Edition IDE to write and run our "Hello World" Python program.

Step #1: Create New Project

When you open the IDE you will see the following. Select the first option 'Create New Project'.

pycharm community edition - create new project

Or, if you are already in a project then click on File then select New Project.

pycharm community edition - create new project

Step #2: New Project

Set the location of your project on your computer and select the base interpreter.

In the following example I have named my project HelloWorld and selected Python 3.7.

pycharm community edition - name the project

Step #3: Create a new Python file

Now right click on the project folder HelloWorld, then select New and then click on Python File.

pycharm community edition - new python file

Now, name the file HelloWorld and click on the OK button.

pycharm community edition - new python file name

This will create a new Python file HelloWorld.py inside the project folder.

Step #4: Write the "Hello World" program in Python

Inside the HelloWorld.py file write the following code.

print("Hello World")

Step #5: Run "Hello World" program

Save your program and click on Run and then click on Run 'HelloWorld'.

pycharm community edition - run hello world program

This will open the in-built Run console of PyCharm IDE and you will get to see the output "Hello World".

pycharm community edition - run hello world program output

And this brings us to the end of this tutorial. In the next tutorial we will dive deep into Python programming langauge.

If you find this tutorial and this website interesting and helpful then do share it on social media with your friends.

See you in the next tutorial. Have fun programming.

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT