forked from KaistLecture/FEProgramming1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code_160224.py
149 lines (116 loc) · 1.75 KB
/
code_160224.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
'''
a = list("ABCDEF")
for i, value in enumerate(a):
print(i, end=" ")
print(value+"s")
'''
import random
e=0
while e>-2:
e = random.gauss(0,1)
print(e)
#if e<-2:
#break
print("END")
#실습 코드
data_file = open('us_cities.txt','r')
data_file
next(data_file)
temp = next(data_file)
temp
type(temp)
temp2 = temp.split(":")
temp2
temp2[0]
temp2[1]
int(temp2[1])
temp = next(data_file)
temp
temp2 = temp.split(":")
temp2
temp2[1]
a = temp2[1]
a = a.rstrip("\n")
a
a = [1,2,3]
# next(a) #error: list is not an iterator
b = iter(a)
b
next(b)
a = range(10)
a
list(a)
a
#next(a) #error: range is not an iterator either
b = iter(a)
b
next(b)
list("ABCE")
b= enumerate(a)
next(b)
f = open("us_cities.txt",'r')
a = 10
a = a + 1
a
a += 1
a
a
a *= 2
a
a = a*2
import random
random.gauss(10,20)
import datetime
import datetime as dt
dt
from datetime import datetime
datetime
from datetime import date
date
import random
from random import gauss
gauss(0,1)
import scipy.stats
scipy.stats.norm.cdf(0)
scipy.stats.norm.cdf(-1)
import scipy.stats as ss
ss.norm.cdf(0)
from scipy.stats import norm as foo
foo.cdf(0)
a>50
not a>50
x = 100
if x>90:
y = "G"
else:
y = "L"
y
y = "G" if x>90 else "L"
y
y = "G" if x>90 else "L" if x>70 else "A"
x = 75
y = "G" if x>90 else "L" if x>70 else "A"
y
x = 50
y = "G" if x>90 else "L" if x>70 else "A"
y
y = "G" if x>90 else ("L" if x>70 else "A")
a = list(range(-5,6))
a
b = [0 if x<0 else 1 for x in a]
b
b = [int(x>=0) for x in a]
b
b = [x for x in a if x>0]
b
#b = [x for x in a if x>0 else x**2] #Wrong
b = [x if x>0 else x**2 for x in a]
b
#b = [x if x>0 for x in a] #Wrong
b = [x+1 for x in a]
b
b = [x+1 for x in a if x>0]
b
b = [x+1 if x>0 else x-1 for x in a]
b
a,b,c=[],[],[]