Here we will run a simple program to print hello world

We can run Python program by using two ways:


  1. By Intractive interpeter prompt
  2. By Script file


1. By Intractive interpeter prompt:


In Intractive interpeter prompt we can execute Python statement one by one.

To run python in Intractive mode open your CMD(Command Prompt) and type python.




To print "Hello World", type "print("Hello World") and hit enter.



2. By Script file:

We cannot write code on Command Prompt at every time, so we need to write our code on "text" file and save the text file as extension ".py" (Eg:  sample.py).

Eg:
            Open your text editor and type the below code and save the file name as "sample.py"

        print("Hello World")






To run the python program type "python sample.py" and hit enter and we will get the output as "Hello World".

Indentation:

In other programming languages indentation is not important but in python indentation is very important. Python uses indentation for blocks, instead of curly braces.

Eg:

             if 5>2:
               print("SVRR TECH")





Post a Comment

Previous Post Next Post