-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhow_to_use_python.py
84 lines (65 loc) · 1.16 KB
/
how_to_use_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# int doSomething(int arg1, int arg2) {
# ...
# return(1);
# }
def do_something(arg1=1, arg2=2):
return 1
do_something()
do_something(5)
do_something(5, 6)
do_something(arg2=6)
# for (int i = 0, i < 10, i++) {
# printf(i);
# }
for i in range(10):
print(i)
print(list(range(-10, 10, 2)))
a = 1
b = 2
if a == 5:
print('a is 5')
elif b == 5:
print('b is 5')
else:
print('neither was 5 :(')
# public class A {
# int val;
# void A() {
# this.val = 0;
# return;
# }
# }
class A():
def __init__(self):
self.val = 0
return
b = list()
b = []
b = [1,2,3]
b.append(4)
b = [i for i in range(1,5)] # [1,2,3,4]
b = []
for i in range(1,5):
b.append(i)
# b = [1,2,3,4]
c = set()
# unordered, unique collection
c = set([1,2,2,3]) # {1,2,3}
c = {1,2,2,3} # {1,2,3}
c.add(4) # {1,2,3,4}
d = dict()
d = {'a':1, "b":2}
print(d['a'])
# in operator
# : operator (slicing)
import numpy as np
b = np.array([i for i in range(10)])
print(b)
print(slice(2,5))
print(b[2:5])
print(b[-1])
print(b[0:-2])
def difference(original_image, attack_image):
# compute metric for difference
score = 0
return score