-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path830실습
87 lines (68 loc) · 1.45 KB
/
830실습
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
83
84
85
86
87
def g(x=3):
result=x+1
return result
g()
print(g)
import inspect
print(inspect.getsource(g))
import numpy as np
x=np.array([1,-2,3,-4,0])
con=[x>0, x==0,x<0]
choices=["양수","0","음수"]
result=np.select(con, choices)
# for loop
for i in range(1,4):
print(f"Here is {i}")
[f"Here is {i}" for i in range(1,4)]
name="John"
age="30"
f"Hello, my name is {name} and I am {age} year old."
greetings=[f"이름:{name}, 나이:{age}."for name, age in zip(name, age)]
i=0
while i>10:
i+=3
print(i)
import pandas as pd
data=pd.DataFrame({
"A":[1,2,3],
"B":[4,5,6]
})
data.apply(sum, axis=0)
data.apply(sum, axis=1)
def my_func(x, const=3):
return max(x)**2 + const
my_func([4,5,6,7],3)
# 함수 환경
def my_func(x):
y=1
result= x+y
return result
#-------------------------------
def outer_func():
def inner_func(input):
return input + 2
# check env of inner_func()
print(inner_func.__code__.co_varnames)
outer_func()
def my_func(x):
global y
y+=1
return x + y
my_func(3)
def add_many(*args):
result=0
for i in args:
result +=i
return result
add_many([1,2,3])
def first_many(*args):
return args[0]
**별표 두 개는 키워드르 딕셔너리로 만들어줌
def my_twostars(choice, **kwargs):
if choice =="first":
return kwargs[0]
elif choice =="second":
return kwargs[0]
else:
return kwargs
my_twostars("second", age=30,name="issac")