Skip to content

Commit 10cff48

Browse files
committed
First session
0 parents  commit 10cff48

File tree

6 files changed

+420
-0
lines changed

6 files changed

+420
-0
lines changed

class_01/.ipynb_checkpoints/class_01-checkpoint.ipynb

+167
Large diffs are not rendered by default.

class_01/class_01.ipynb

+167
Large diffs are not rendered by default.

class_01/main.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
print "hello world!"
2+
# write a function
3+
# add(1, 2, 3)
4+
5+
a = 1
6+
print a
7+
8+
a = 'abc'
9+
print a
10+
11+
b = "abc"
12+
print a==b
13+
14+
#string, lists and dicts
15+
16+
l = []
17+
print l
18+
19+
l.append('a')
20+
print l
21+
22+
l1 = list([1, 2, 3])
23+
print l1
24+
25+
L = [1, 2, 'abc', [11, 11.91, 1e-10], None]
26+
print type(L)
27+
print type(1.0), type(1), type('a'), type("abc")
28+
print [1, 2] + [3, 4]
29+
30+
print L[-2]
31+
32+
a = [1, 3, 2, 4, 6, 2, 4, 'a']
33+
print a[::-1]
34+
35+
# list[start:(end+1):skip]
36+
37+
# dictionary
38+
d = {'k': 'v', 'k2':'value2', 2: 'abc', 'l': 1.0}
39+
print d
40+
41+
a = """
42+
This is a comment
43+
"""
44+
45+
def fname(c, a=1, b=0, **kwargs):
46+
# print args
47+
print kwargs
48+
# return sum(args)
49+
return a**2 + b + c
50+
b = 20
51+
print fname(3, b=b, a=20, f1=10, f2=20)
52+
pack = 10
53+
print pack
54+
55+
import pack
56+
print pack
57+
58+
print pack.add(1, 3, 2, 5, 4)

class_01/myfile.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
this is a file.
2+
Welcome to Perceptron.
3+
We are learnning python.

class_01/pack.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import math
2+
3+
def add(*args):
4+
return sum(args)
5+
6+
7+
class A:
8+
def __init__(self, x=1, y=2):
9+
self.x = x
10+
self.y = y
11+
12+
def fname(a, l=None):
13+
l = list(l)
14+
l.append(a)
15+
return l
16+
17+
18+
if __name__ == '__main__':
19+
v1 = fname(1)
20+
v2 = fname('a', ['b'])
21+
v3 = fname(100)
22+
23+
print v1
24+
print v2
25+
print v3

class_01/pack.pyc

634 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)