In Programming world printing a Hello World! message to the screen will be the first program in a new programming language.
We can Run python program,
- In Interpreter prompt and,
- In Script file
1. Interpreter Prompt
Python comes with an interpreter that run in Command Prompt window, in this window we can try bits of python program without saving the entire program. To run python interpreter mode, Run command prompt and type “Python”. To execute the code hit enter.
C:\Users\NeuralBeast>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
In Python we can write the Hello World! program in one line, the example is given below.
Example:
>>> print("Welcome To Neural Beast's Python Tutorial")
Welcome To Neural Beast's Python Tutorial
>>>
To close interpreter prompt type exit() command and hit enter.
Python on cross-platform
Python is a cross-platform language, hence it runs on all the major Operating System.
Python on Linux
Linux operating system is mainly designed for programmers, so python is already installed on most of the Linux system. In python we need to change some few settings to start programming.
To Run python prompt, open your Terminal window, to check whether python is installed, type python and hit enter, this will open python prompt with >>> symbols.
$ python
Python 3.8.2 (default, Sep 18 2014, 22:59:38)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
To Run python code on terminal type,
>>> print("Welcome To Neural Beast's Python Tutorial")
Welcome To Neural Beast's Python Tutorial
>>>
To close the python interpreter type exit() and hit enter.
2. Script File
In this type we can save our entire python code in a text file with the extension as .py (Eg: “hello.py“).
To run python script file, first navigate the prompt to the folder where you have saved the python script, to do that use cd command, the cd command is change directory, is used to navigate through your file in command prompt. file and simply type “python” and “name of the script file” in command prompt.
Example:
D:\python>python hello.py
Welcome to Neural Beast's Python Tutorial
D:\python>
Super bro, it is very useful.
I pay a quick visit every day some web pages and websites to read articles, however
this blog gives feature based writing.
I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.