linux-python

in #python7 years ago

This blog is to give a brief code about python

the following are simple use of python command line..

python 2.7 interpreter introduction commands!
pg-48@pg48-Precision-Tower-3620:~$ python2
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.

print "Hello python!"
Hello python!
x = 4
x
4
y = 2
y
2
x+y
6
x-y
2
xy
8
x/y
2
x%y
0
x
*y
16

s = 'python'
s
'python'
s[0]
'p'
s[0:2]
'py'
s[2:5]
'tho'
x*s
'pythonpythonpythonpython'

list = [1,2.5,'python']
list
[1, 2.5, 'python']
list.append(x)
list
[1, 2.5, 'python', 4]

for i in range(10):
... print i
...
0
1
2
3
4
5
6
7
8
9

for i in range(10):
... print i*i
...
0
1
4
9
16
25
36
49
64
81

for i in list:
... print i
...
1
2.5
python
4