Python Day1 1
Python Day1 1
9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\seema>cd ..
C:\Users>cd ..\
C:\>cd Python27
C:\Python27>dir
Volume in drive C is Windows
Volume Serial Number is A806-62A4
Directory of C:\Python27
07-02-2014
07-02-2014
07-02-2014
07-02-2014
07-02-2014
08-02-2014
07-02-2014
10-11-2013
10-11-2013
10-11-2013
10-11-2013
27-10-2013
07-02-2014
07-02-2014
07-02-2014
10-11-2013
23:34
<DIR>
.
23:34
<DIR>
..
23:31
<DIR>
DLLs
23:31
<DIR>
Doc
23:31
<DIR>
include
02:12
<DIR>
Lib
23:31
<DIR>
libs
19:28
38,573 LICENSE.txt
11:14
375,685 NEWS.txt
19:24
26,624 python.exe
19:24
27,136 pythonw.exe
17:00
55,208 README.txt
23:34
<DIR>
Scripts
23:31
<DIR>
tcl
23:31
<DIR>
Tools
19:23
49,664 w9xpopen.exe
6 File(s)
572,890 bytes
10 Dir(s) 437,429,100,544 bytes free
C:\Python27>python.exe
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> cls
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cls' is not defined
>>> clear
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'clear' is not defined
>>> cls
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cls' is not defined
>>> a=[cccc,dddd,ffff,gggffe,hhh,jjj,ttt,bttt,aaaaaaaaaaaaaazzz]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cccc' is not defined
>>> a = [cccc,dddd,ffff,gggffe,hhh,jjj,ttt,bttt,aaaaaaaaaaaaaazzz]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cccc' is not defined
>>> a = ['cccc','dddd','ffff','gggffe','hhh','jjj','ttt','bttt','aaaaaaaaaaaaaaz
zz']
>>>
>>>
>>> sorted(a)
['aaaaaaaaaaaaaazzz', 'bttt', 'cccc', 'dddd', 'ffff', 'gggffe', 'hhh', 'jjj', 't
tt']
>>> a = ['cccc','dddd','ffff','gggffe','hhh','jjj','ttt','bttt','aaaaaaaaaaaaaaz
zz','aaaabbbbbcc','acbbb']
>>> sorted(a)
['aaaaaaaaaaaaaazzz', 'aaaabbbbbcc', 'acbbb', 'bttt', 'cccc', 'dddd', 'ffff', 'g
ggffe', 'hhh', 'jjj', 'ttt']
>>> sorted(a, key=len)
['hhh', 'jjj', 'ttt', 'cccc', 'dddd', 'ffff', 'bttt', 'acbbb', 'gggffe', 'aaaabb
bbbcc', 'aaaaaaaaaaaaaazzz']
>>>
>>>
>>>
>>>
>>>
>>> sorted(a, key=len)
['hhh', 'jjj', 'ttt', 'cccc', 'dddd', 'ffff', 'bttt', 'acbbb', 'gggffe', 'aaaabb
bbbcc', 'aaaaaaaaaaaaaazzz']
>>> '-'.join(a)
'cccc-dddd-ffff-gggffe-hhh-jjj-ttt-bttt-aaaaaaaaaaaaaazzz-aaaabbbbbcc-acbbb'
>>> b='-'.join(a)
>>> b
'cccc-dddd-ffff-gggffe-hhh-jjj-ttt-bttt-aaaaaaaaaaaaaazzz-aaaabbbbbcc-acbbb'
>>> b,split('-')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'split' is not defined
>>> b.split('-')
['cccc', 'dddd', 'ffff', 'gggffe', 'hhh', 'jjj', 'ttt', 'bttt', 'aaaaaaaaaaaaaaz
zz', 'aaaabbbbbcc', 'acbbb']
>>> result=[]
>>> for s in a:
... result.append(s)
...
>>> result
False
>>> d.keys()
['a', 'b', 'o', 'g']
>>> d
{'a': 'alpha', 'b': 'beta', 'o': 'omega', 'g': 'gamma'}
>>> d.values()
['alpha', 'beta', 'omega', 'gamma']
>>> for a in sorted(d.keys()):
... print 'key:' , a , '->', d[k]
...
key: a ->
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'k' is not defined
>>> for a in sorted(d.keys()):
... print 'key:' , a , '->', d[a]
...
key: a -> alpha
key: b -> beta
key: g -> gamma
key: o -> omega
>>> for tuple in d.items"
File "<stdin>", line 1
for tuple in d.items"
^
SyntaxError: EOL while scanning string literal
>>> for tuple in d.items
File "<stdin>", line 1
for tuple in d.items
^
SyntaxError: invalid syntax
>>> for tuple in d.items:
... print tuple
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'builtin_function_or_method' object is not iterable
>>> d.items()
[('a', 'alpha'), ('b', 'beta'), ('o', 'omega'), ('g', 'gamma')]
>>> d
{'a': 'alpha', 'b': 'beta', 'o': 'omega', 'g': 'gamma'}
>>>
>>> for tuple in d.items():
... print tuple
...
('a', 'alpha')
('b', 'beta')
('o', 'omega')
('g', 'gamma')
>>> for tuple in d.items:
... print tuple
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'builtin_function_or_method' object is not iterable
>>> d
{'a': 'alpha', 'b': 'beta', 'o': 'omega', 'g': 'gamma'}
>>> d.items()
[('a', 'alpha'), ('b', 'beta'), ('o', 'omega'), ('g', 'gamma')]
>>> d