In the previous topics we have seen the salient features of python,I this tutorial we will see the basic "Hello World!" programming in python on linux.
STEPS
- Open the terminal (ctrl+alt+T)
- After installing the latest version of python type vi filename.py eg:- vi p1.py (create a file)
- Type #!/usr/bin/python (this is called as shebang statement-this is for making the interpreter to realize which statement it is executing).
- write print ("Hello world!")
- don't put semicolon at the end of program like in C.
if we want to check where python is installed
which python or whereis python
To display Universal language in python:-
- Go to www.jrgraphix.net
- Go to code tab-> unicode character Table
- Choose a language
- ie if in Malayalam language i want to write my name note the corresponding code ie to write "NITHIN"
- print (u"\u0D28" + u"\u0D3F" +u"\u0D24" +u"\u0D3F" +u"\u0D7B")
- To run the file type python p1.c
Commenting:
# for single line comment
eg #hello
''' for multiline comment
eg ''' hello how
are you '''
Difference between ' '' ''' (single double and triple quotes)
all are same i.e used to print string but:
(' single quote)- e.g 'today"s date' will print today"s date
(" double quote)- e.g "today's date" will print today's date
(''' Triple quote)- e.g '''today's date
is 16/10/2017''' for line continuation.
SAMPLE:
In th next topics we will cover Basic Data Types in Python..
Thank you..
eg ''' hello how
are you '''
Difference between ' '' ''' (single double and triple quotes)
all are same i.e used to print string but:
(' single quote)- e.g 'today"s date' will print today"s date
(" double quote)- e.g "today's date" will print today's date
(''' Triple quote)- e.g '''today's date
is 16/10/2017''' for line continuation.
SAMPLE:
In th next topics we will cover Basic Data Types in Python..
Thank you..
Good Article
ReplyDelete