Oracle, Web, Script, SQLserver, Tips & Trick

February 14, 2012

Google python class with Nick Parlante (text version)

Filed under: phyton — sikathabis @ 10:01 am
Tags:

www.youtube.com/watch?v=tKTZoB2Vjuk

www.youtube.com/watch?v=EPYupizJYQI

www.youtube.com/watch?v=haycL41dAhg

Day 1 part 1

C:\Python32>python hello.py asdasd vsdf dfdf
Hello
[‘hello.py’, ‘asdasd’, ‘vsdf’, ‘dfdf’]
6
4
4
Hello hello.py!!!!

C:\Python32>python hello.py asdasd vsdf dfdf
File “hello.py”, line 5
def Hello(name) {
^
SyntaxError: invalid syntax

C:\Python32>python hello.py asdasd vsdf dfdf
File “hello.py”, line 8
}
^
SyntaxError: invalid syntax

C:\Python32>python hello.py asdasd vsdf dfdf
Hello
[‘hello.py’, ‘asdasd’, ‘vsdf’, ‘dfdf’]
6
4
4
Hello hello.py!!!!

C:\Python32>python hello.py asdasd vsdf dfdf
Hello
[‘hello.py’, ‘asdasd’, ‘vsdf’, ‘dfdf’]
6
4
4
Hello hello.py!!!!

C:\Python32>python hello.py asdasd vsdf dfdf
Hello
[‘hello.py’, ‘asdasd’, ‘vsdf’, ‘dfdf’]
6
4
4
Hellohello.py!!!!

C:\Python32>python hello.py asdasd vsdf dfdf
Hello
[‘hello.py’, ‘asdasd’, ‘vsdf’, ‘dfdf’]
6
4
4
Hellohello.py!!!!
Hello hello.py!!!!

C:\Python32>python hello.py asdasd vsdf dfdf
File “hello.py”, line 8
else
^
SyntaxError: invalid syntax

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Traceback (most recent call last):
File “hello.py”, line 22, in <module>
main()
File “hello.py”, line 19, in main
Hello(sys.argv[1])
File “hello.py”, line 9, in Hello
endif
NameError: global name ‘endif’ is not defined

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Traceback (most recent call last):
File “hello.py”, line 23, in <module>
main()
File “hello.py”, line 20, in main
Hello(sys.argv[1])
File “hello.py”, line 8, in Hello
endif
NameError: global name ‘endif’ is not defined

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Traceback (most recent call last):
File “hello.py”, line 22, in <module>
main()
File “hello.py”, line 19, in main
Hello(sys.argv[1])
File “hello.py”, line 8, in Hello
endif
NameError: global name ‘endif’ is not defined

C:\Python32>python hello.py taufan vsdf dfdf
File “hello.py”, line 8
endif:
^
SyntaxError: invalid syntax

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Traceback (most recent call last):
File “hello.py”, line 23, in <module>
main()
File “hello.py”, line 20, in main
Hello(sys.argv[1])
File “hello.py”, line 10, in Hello
endif
NameError: global name ‘endif’ is not defined

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Hellotaufan?????
Hello taufan?????

C:\Python32>python hello.py taufanx vsdf dfdf
Hello
[‘hello.py’, ‘taufanx’, ‘vsdf’, ‘dfdf’]
7
4
4
Hellotaufanx!!!!
Hello taufanx!!!!

C:\Python32>python hello.py alifa vsdf dfdf
Hello
[‘hello.py’, ‘alifa’, ‘vsdf’, ‘dfdf’]
5
4
4
Helloalifa?????
Hello alifa?????

C:\Python32>python hello.py a vsdf dfdf
Hello
[‘hello.py’, ‘a’, ‘vsdf’, ‘dfdf’]
1
4
4
Helloa!!!!
Hello a!!!!

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Hellotaufan?????
Hello taufan?????

C:\Python32>python hello.py taufan vsdf dfdf
Hello
[‘hello.py’, ‘taufan’, ‘vsdf’, ‘dfdf’]
6
4
4
Hellotaufan?????
Hello taufan?????

C:\Python32>python hello.py taufanx vsdf dfdf
Hello
[‘hello.py’, ‘taufanx’, ‘vsdf’, ‘dfdf’]
7
4
4
Traceback (most recent call last):
File “hello.py”, line 22, in <module>
main()
File “hello.py”, line 19, in main
Hello(sys.argv[1])
File “hello.py”, line 9, in Hello
DoesNotExist(name)
NameError: global name ‘DoesNotExist’ is not defined

C:\Python32>python hello.py taufanx vsdf dfdf
Hello
[‘hello.py’, ‘taufanx’, ‘vsdf’, ‘dfdf’]
7
4
4
Traceback (most recent call last):
File “hello.py”, line 22, in <module>
main()
File “hello.py”, line 19, in main
Hello(sys.argv[1])
File “hello.py”, line 9, in Hello
DoesNotExist(name)
NameError: global name ‘DoesNotExist’ is not defined

C:\Python32>python
Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win
32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> “u \”asd”
‘u “asd’
>>> a=”monye/”t”
File “<stdin>”, line 1
a=”monye/”t”
^
SyntaxError: invalid syntax
>>> a = “monye/”t”
File “<stdin>”, line 1
a = “monye/”t”
^
SyntaxError: invalid syntax
>>> a = ‘monye”t’
>>> a
‘monye”t’
>>> a.upper()
‘MONYE”T’
>>> a.lower()
‘monye”t’
>>> a.upcase()
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
AttributeError: ‘str’ object has no attribute ‘upcase’
>>> a.ucase()
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
AttributeError: ‘str’ object has no attribute ‘ucase’
>>> a.find(‘x’)
-1
>>> a.find(‘”‘)
5
>>> a.find(‘m’)
0
>>> a = ‘monyetkum”
File “<stdin>”, line 1
a = ‘monyetkum”
^
SyntaxError: EOL while scanning string literal
>>> a = ‘monyetkum’
>>> a.find(‘m’)
0
>>> a.find(‘m’,2)
8
>>> a[0]
‘m’
>>> a[90]
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
IndexError: string index out of range
>>> ‘hi %s i have %d donuts’ % (‘alice’,42)
‘hi alice i have 42 donuts’
>>> a = ‘hello’
>>> a[0]
‘h’
>>> leng(a)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
NameError: name ‘leng’ is not defined
>>> len(a)
5
>>> len(a[0])
1
>>> a[1:3]
‘el’
>>> a[1:4]
‘ell’
>>> a[1:5]
‘ello’
>>> a[1:]
‘ello’
>>> a[:]
‘hello’
>>> a[-5]
‘h’
>>> a[abs(-5)]
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
IndexError: string index out of range
>>> a[-5:-1]
‘hell’
>>> a[-5:-3]
‘he’
>>> a[:-3]
‘he’
>>> a[-3:]
‘llo’
>>>

download hello.py

Day 1 part 2

>>> a = [1,2,3]
>>> len(a)
3
>>> a = [1,2,’aaa’]
>>> a
[1, 2, ‘aaa’]
>>> b=a
>>> b
[1, 2, ‘aaa’]
>>> a
[1, 2, ‘aaa’]
>>> a[0]
1
>>> a[2]
‘aaa’
>>> a[2]
‘aaa’
>>> a[1]
2
>>> a[0]=13
>>> b
[13, 2, ‘aaa’]
>>> a
[13, 2, ‘aaa’]
>>> b=a[:]
>>> a
[13, 2, ‘aaa’]
>>> b
[13, 2, ‘aaa’]
>>> a[0]=30
>>> a
[30, 2, ‘aaa’]
>>> b
[13, 2, ‘aaa’]
>>> a == b
False
>>> a[0]=13
>>> a == b
True
>>> a[1:3]
[2, ‘aaa’]
>>> a[:-1]
[13, 2]
>>> a
[13, 2, ‘aaa’]
>>> b
[13, 2, ‘aaa’]
>>> for v in a:
print v

SyntaxError: invalid syntax
>>> for v in a:
print(v)
13
2
aaa
>>> for v in a:
if > 0

SyntaxError: invalid syntax
>>> for v in a:
if a[v] in a

SyntaxError: invalid syntax
>>> ‘aaa’ in a
True
>>> ‘aa’ in a
False
>>> a.append(4)
>>> a
[13, 2, ‘aaa’, 4]
>>> b
[13, 2, ‘aaa’]
>>> a
[13, 2, ‘aaa’, 4]
>>> none
Traceback (most recent call last):
File “<pyshell#42>”, line 1, in <module>
none
NameError: name ‘none’ is not defined
>>> None
>>> Null
Traceback (most recent call last):
File “<pyshell#44>”, line 1, in <module>
Null
NameError: name ‘Null’ is not defined
>>> null
Traceback (most recent call last):
File “<pyshell#45>”, line 1, in <module>
null
NameError: name ‘null’ is not defined
>>> None
>>> a=a.append(xx)
Traceback (most recent call last):
File “<pyshell#47>”, line 1, in <module>
a=a.append(xx)
NameError: name ‘xx’ is not defined
>>> a.pop(0)
13
>>> a
[2, ‘aaa’, 4]
>>> a.replace(a[1],3)
Traceback (most recent call last):
File “<pyshell#50>”, line 1, in <module>
a.replace(a[1],3)
AttributeError: ‘list’ object has no attribute ‘replace’
>>> a.modify(a[1],3)
Traceback (most recent call last):
File “<pyshell#51>”, line 1, in <module>
a.modify(a[1],3)
AttributeError: ‘list’ object has no attribute ‘modify’
>>> del a
>>> a
Traceback (most recent call last):
File “<pyshell#53>”, line 1, in <module>
a
NameError: name ‘a’ is not defined
>>> a = [1,2,3]
>>> a[1]
2
>>> del a[1]
>>> a
[1, 3]
>>> b=12
>>> a = b
>>> del a
>>> a
Traceback (most recent call last):
File “<pyshell#61>”, line 1, in <module>
a
NameError: name ‘a’ is not defined
>>> b
12
>>> a = [4,2,1,6]
>>> sorted(a)
[1, 2, 4, 6]
>>> a
[4, 2, 1, 6]
>>> help(sorted)
Help on built-in function sorted in module builtins:

sorted(…)
sorted(iterable, key=None, reverse=False) –> new sorted list

>>> sorted(a,None,True)
Traceback (most recent call last):
File “<pyshell#67>”, line 1, in <module>
sorted(a,None,True)
TypeError: must use keyword argument for key function
>>> sorted(a,reverse=True)
[6, 4, 2, 1]
>>> a
[4, 2, 1, 6]
>>> a = [‘ccc’,’aaa’,’d’,’bb’]
>>> sorted(a)
[‘aaa’, ‘bb’, ‘ccc’, ‘d’]
>>> sorted(len(a))
Traceback (most recent call last):
File “<pyshell#72>”, line 1, in <module>
sorted(len(a))
TypeError: ‘int’ object is not iterable
>>> sorted(a,len(a))
Traceback (most recent call last):
File “<pyshell#73>”, line 1, in <module>
sorted(a,len(a))
TypeError: must use keyword argument for key function
>>> a=[‘ccc’,’aaaa’,’d’,’bb’]
>>> sorted(a,len)
Traceback (most recent call last):
File “<pyshell#75>”, line 1, in <module>
sorted(a,len)
TypeError: must use keyword argument for key function
>>> sorted(a,len(a))
Traceback (most recent call last):
File “<pyshell#76>”, line 1, in <module>
sorted(a,len(a))
TypeError: must use keyword argument for key function
>>> len
<built-in function len>
>>> sorted(a,key=len)
[‘d’, ‘bb’, ‘ccc’, ‘aaaa’]
>>> sorted(a,key=len,reserve=True)
Traceback (most recent call last):
File “<pyshell#79>”, line 1, in <module>
sorted(a,key=len,reserve=True)
TypeError: ‘reserve’ is an invalid keyword argument for this function
>>> sorted
<built-in function sorted>
>>> a
[‘ccc’, ‘aaaa’, ‘d’, ‘bb’]
>>> a[1]=’aaaz’
>>> sorted (a,key=last)
Traceback (most recent call last):
File “<pyshell#84>”, line 1, in <module>
sorted (a,key=last)
NameError: name ‘last’ is not defined
>>> sorted(a,key=Last)
Traceback (most recent call last):
File “<pyshell#85>”, line 1, in <module>
sorted(a,key=Last)
NameError: name ‘Last’ is not defined
>>> def last(s): return s[-1]
sorted(a,key=last)
SyntaxError: invalid syntax
>>> Traceback (most recent call last):

SyntaxError: invalid syntax
>>> a
[‘ccc’, ‘aaaz’, ‘d’, ‘bb’]
>>> last(a)
Traceback (most recent call last):
File “<pyshell#90>”, line 1, in <module>
last(a)
NameError: name ‘last’ is not defined
>>> Last(a)
Traceback (most recent call last):
File “<pyshell#91>”, line 1, in <module>
Last(a)
NameError: name ‘Last’ is not defined
>>> Last
Traceback (most recent call last):
File “<pyshell#92>”, line 1, in <module>
Last
NameError: name ‘Last’ is not defined
>>> def Last(s):
return (s[-1])

>>> Last(a)
‘bb’
>>> sorted(a,key=Last)
[‘bb’, ‘ccc’, ‘d’, ‘aaaz’]
>>>

>>> ‘:’.join(a)
‘ccc:aaaz:d:bb’
>>> ‘\m’.join(a)
‘ccc\\maaaz\\md\\mbb’
>>> b=’:’.join(a)
>>> ‘:’.split(b)
[‘:’]
>>> b.split(‘:’)
[‘ccc’, ‘aaaz’, ‘d’, ‘bb’]
>>> result = []
>>> for s in a: result.append(s)

>>> result
[‘ccc’, ‘aaaz’, ‘d’, ‘bb’]
>>> range(20)
range(0, 20)
>>> for i in range(20)
SyntaxError: invalid syntax
>>> for i in range(20) :
print (i)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Teknologi Pendidikan

Just another WordPress.com weblog

KATAKAMI

Jurnalisme Yang Dapat Dipercaya

Tonk Kosonk Baonk Bunyinya

Penampungan Serapah Tanpa Sumpah

Qey050489's Blog

Ayo Bangkit sobat..!!!!!

B. S. Totoraharjo

Orang Bodoh Yang Tak Kunjung Pandai

culturekitchen foodlab

New Food and Art in Yogyakarta

Wahyu Catur Wibowo

Musafir Dunia Maya

SQL.... Still Learning

My Reference on SQL Server

neinframe

Street Photography is like a box of a chocolates, you're never know what you're gonna get - Thomas Leuthard -

Keluarga Andrivito

-- Andrivito's Journal --

DRK™

This site is about Latest NEWS, Articles, Videos, Books, Course, Presentations, Tips & Tricks related to I.T Pro's

Gaurav Saxena

|| तत् त्वम् असि ||

Be a good Moeslim

Menuju Pribadi Muslim Sejati yang Bertaqwa

TuanSUFI

Manajemen Sholat, renungan spiritual, Teknologi Informasi

Pelangi di khatulistiwa....

Mari berbagi kebaikan, pengalaman dan senyum denganku

angkasa13

Ceritanya saya, Pikirannya saya, Hatinya saya

sikathabis

sikathabis semua informasi disini

%d bloggers like this: