>>> print("Hello World!")
Hello World!
More on intalling python can be found here - Install Python
The Python interpreter is usually installed as /usr/local/bin/python3.7
on those machines where it is available; putting /usr/local/bin
in your Unix shell’s search path makes it possible to start it by typing the command:python3.7
to the shell.
Since the choice of the directory where the interpreter lives is an installation option, other places are possible; check with your local Python guru or system administrator. (E.g., /usr/local/python
is a popular alternative location.)
On Windows machines, the Python installation is usually placed in C:\Python37
, though you can change this when you’re running the installer. To add this directory to your path, you can type the following command into the command prompt in a DOS box:
set path=%path%;C:\python37
$ python3.7
Python 3.7 (default, Sep 16 2015, 09:25:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print("Hello World!")
Hello World!
>>> 2+6
8
More on interactive mode will be find here - https://docs.python.org/3/tutorial/interpreter.html#interactive-mode
Open your favorite text editor (e.g., vi, Notepad, or the IDLE editor),type the following statements into a new text file named script1.py, and save it in your working code directory. .
print(“Hello User!”)
Once You have saved the file you can run it with command window. Move to the directory in which you have saved the script. Then type python command and then the file name with .py extension to execute the scripts. You will get the following result.
C:\code> python script1.py
Hello User!
A comment starts with a hash character (#
) and ends at the end of the physical line.
In the below code, print('Hello user') is commented. So when you run the script1.py it will not print "Hello user". Check the output
print('Hello World')
# print('Hello user')
Hello World
The indentation rule may seem unusual at first glance to programmers accustomed to C-like languages, but it is a deliberate feature of Python, and it’s one of the main ways that Python almost forces programmers to produce uniform, regular, and readability.
if x:
if y:
statement1
else:
statement2
Nested statements are blocked and associated by their physical indentation(without braces).
More on indentaion can be found here https://docs.python.org/3/reference/lexical_analysis.html#indentation