1 # print("輸入成績",end="")
2 # src=input()
3 # print("成績",end=src)#成績
4 # print("sdf",end="." )
5 # print("wedf")#不換行
6 # s="aba"
7 # s=123
8 # s=[1,2,3]
9 # s='print("hello")'
10 # eval(s)e 二次編譯
11 # print(0x12)16進 制
12 # print(3e3) 十進制,e表示十的多少次方
13 # print(r"a/nb")r表示不須要轉義符
14 # print('''
15 # a
16 # s
17 # d
18 # f
19 # d
20 # ''')三個引號,表示多重,不須要
21 # x=2>0 and 3<4 or 50<40
22 # print(x)布爾類型,首字母大寫
23
24 # y=False
25 # t="12233"
26 # t=None
27 # print(t)
28
29 # 常量
30 # c除數,/ 餘數%
31 # 對於單個字符的編碼,Python 提供了 ord()函數獲取字符的整數表示,
32 # chr()函數把編碼轉換爲對應的字符
33 # print(5/40)
34 # print(ord("中"))
35 # print(chr(20013))
36 # 以 Unicode 表示的 str 經過 encode()方法能夠編碼爲指定的 bytes,
37 # print('中文'.encode('UTF-8'))
38 # print('中文'.encode('gb2312'))
39
40 # 要把 bytes 變爲 str,就須要用 decode()方法:
41 # >>> b'ABC'.decode('ascii')
42 # 'ABC'
43 # >>> b'\xe4\xb8\xad\xe6\x96\x87'.decode('utf-8')
44 # '中文'
45 # print(len("abcsd"))長度
46 # name,age,sid='張三',19,100000
47 # # print(name,age)
48 # print("我叫%s,年齡%d,學號%s"%(name,age,sid))佔位符
49 # %d 整數
50 # %f 浮點數
51 # %s 字符串
52 # %x 十六進制整數
53 # a=b=1
54 # print(a,b)
55 # for i in range(1,10):斐波拉數
56 # c=a+b
57 # a,b=b,a+b
58 # print(c,end=" ")
59 # for ch in range(1,128):ascii編碼
60 # # 'i'.encode('ascii')
61 # # print("%d\t%s" %(i,chr(i)))
62 # print("%s %d Ox%s"%(chr(ch),ch,ch))
63 # age=18
64 # age=18
65 # age=16
66 # print("成年" if age>15 else "少年")
67 # "成年"if age>20 else "青年" if age>15 else "少年"
68 # 100
69 # 之和
70 # s,i=0,1
71 # while i<=100:
72 # s,i=s+i,i+1
73 # else:
74 # print(s)
75 # #50到100,每次加2:
76 # for i in range(50,100,2)
77 # list長度
78 # ss=[12,34,234,32]
79 # print(len(ss))
80 #尾部插入
81 # ss.append(32)
82 #隨意插入,下標在間隙處,1爲下標
83
84 # ss.insert(1,12)
85 # 下標爲2到5
86 # print(ss[2:5])
87 # 下標爲2到尾部
88 # print(ss[2:])
89 # print(ss[:5])
90 # 下標爲-2到-5,從左向右
91 # print(ss[-2:-5])
92 # print(ss)
93 # print(len(ss))
94 # ss=[12,3,34,4,]
95 # print(ss)
96 # print(ss[-1:])
97 # ss.pop()
98 # 倒敘
99 # ss=[12,3,34,4,]
100 # yy=[]
101 # while len(ss)>0:
102 # yy.append(ss.pop())
103 # print(yy)
104 ss=[1,2,34,4,5,2,5,2,5,2,5]
105 # print(ss[4][,1,])
106 # yy=[3,34]
107 # 在ss尾部加元素
108 # print(ss+yy)
109 # print(ss+yy*2)
110 # 全部元素
111 # print(ss[:])
112 # 0到5下標,每隔2個下標
113 # print(ss[0:5:2])
114 # 切片
115 # ret="asd sf sd afd".split(" ")
116 # print(ret)
117 # print(ret[1::2])
118
119 # 數的平方
120 # lst=[i*i for i in range(1,10) if i%2==0]
121 # 乘法表
122 # lst=["%d*%d=%d"%(i,j,i*j) for i in range(1,10) for j in range(1,i+1)]
123 # print(lst)
124 # a=[]
125 # int (input(a))
126 #
127 #
128 # print("輸入數字")
129 # for i in range(1,a+1):
130 # j=a/i
131 # a=i*j
132 #
133 # if(i%j==0):
134 # print(a)
135 # 因數
136 # x=input("輸入數字")
137 # for i in range(1,int(x)+1):
138 # j=int(x)/i
139 # if int(x)%i==0:
140 # print("%d*%d=%d"%(i,j,int(x)))
141
142
143
144
145
146
1 # 列表生成式
2 # num=112
3 # ys=("%d=%d*%d"%(num,i,num//i) for i in range(2,num) if num%i==0)
4 # print(ys)
5 # print(list(ys))
6
7
8
9 # ----------------------------------------
10 # 拷貝地址,
11 # list=[1,3,4,5,66,87,8,7,5]
12 # print(list)
13 # lst=list.copy()
14 # print(lst)
15 # list.append(23)
16 # print(list)
17 # 清空數據
18 # print(list.clear())
19 # 調換位置
20 # list.reverse()
21 # print(list)
22 # ---------
23 # 找(元素,下標),從n下標找
24 # print(list.index(1,0))
25
26 # tuple
27 # 另外一種有序列表叫元組:tuple。tuple 和 list 很是相似,可是 tuple 一旦
28 # 初始化就不能修改,
29 # tp=(12,3,4,[123,3423,43],54,3,2)
30 # tp=tp2
31
32 # tp[3].append(45)
33 # print(tp)
34
35 # 只有 1 個元素的 tuple 定義時必須加一個逗號,,來消除歧義:
36 # >>> t = (1,)
37 # >>> t
38 # (1,)
39 # print(range(5))
40 # for s in range(5):
41 # print(s)
42 # print(list(range(5)))
43 # d = {"Michael": 95, 'Bob': 75, 'Tracy': 85}
44 # print(d)
45
46 # dict 的支持,dict 全稱 dictionary,在其餘語言中也
47 # 稱爲 map,使用鍵-值(key-value)存儲,具備極快的查找速度。
48 # 舉個例子,假設要根據同窗的名字查找對應的成績,若是用 list 實現,
49 # 須要兩個 list:
50 # names = ['Michael', 'Bob', 'Tracy']
51 # scores = [95, 75, 85]
52 # d={}
53 # d["張三"]=19
54 # d["張三4"]=18
55 # 是值,去重,後覆蓋前
56 # print(d.values())
57 # 刪除
58
59 # d.pop("張三")
60 # 判斷是否有這個元素,
61 # print("張三"in d)
62 # for key in d.keys():
63 # print("%s成績是%d"%(key,d.get(key)))
64 # for x in d.items():
65 # print("%s成績是%d"%(x[0],x[1]))
66
67
68 # 刪除最後一個
69 # record=d.popitem()
70 #
71 # print(len(d))
72 # print(record)
73 # set 和 dict 相似,也是一組 key 的集合,但不存儲 value。因爲 key 不能
74 # 重複,因此,在 set 中,沒有重複的 key。
75 # 要建立一個 set,須要提供一個 list 做爲輸入集合:
76 # >>> s = set([1, 2, 3])
77 # >>> s
78 # {1, 2, 3}
79 # s=[12,3,4]
80 # print(s)
81 # s=set((121,32,34,32,23))
82 # print(s)
83 # s=set([12,32,233,123])
84 # print(s)
85 # print(tuple((12321,324,2324,234)))
86 # print(tuple([123,1234,3243]))
87 # map轉set
88 # print(list({"張三":12}.items()))
89 # mp={('a','b'):2,('a','c'):2,}
90 # for k in mp:
91 # print(k[0],end='---->')
92 # print(k[1],end=' = ')
93 # print(mp[k])
94 #
95 # import random
96 # 隨機生成字符串
97 # names=['張三','李四','阿斯蒂芬','所發生的']
98 # frints=['ng蘋果','木瓜','西瓜','南瓜']
99 # randnames=[];randfrints=[]
100 # for i in range(len(randnames)):
101 # names=randnames[i];frints=randfrints[i]
102 # print("%s喜歡%s"%(names,frints))
103 #
104 # lst=list(zip(names,frints))
105 # print(lst)
106 # for names,frints in lst:
107 # print("%s喜歡%s" % (names, frints))
108
109 # x=random.choice(['ad','ads','ads'])
110 # print(x)
111
112 # 無參函數
113 # def abc():
114 # print("this is abc")
115 #
116 #
117 # def abc(i):
118 # print("i:%s"%(i))
119 # abc(100)
120 # abc1=abc
121 #
122 # def abc(j):
123 # print("j:%s"%(j))
124 #
125 # abc(100)
126 # abc1(100)
127
128 # i,就,能夠默認,能夠從新賦值
129 # def abc(i,j=34):
130 # print("i:%s j:%s" % (i,j))
131 # abc(100,22)
132 # 輸出i:100 j:22
133 # def abc(i):
134 # print("結果爲%"%(i))
135 # def bcd(f,i,j):
136 # f=(i+j)
137
138 # bcd(abc,10,23)
139 # name=['張三' '19']
140 # info=['男' '南京']
141 # def abc(name ,* info):
142 # print("%的屬性%s"%(name,info))
143 # abc('張三', '19','男', '南京')
144 # def aa(name,** info):
145 # print("%s的屬性"%(name))
146 # for k in info:
147 # print("%s的值:%s"%(k,info.get(k)))
148 # def aa(name, **info):
149 # print("%s的屬性"%(name))
150 # print("性別"+info.get('sex')) if info.get('sex')!=None else None
151 # print("年齡" + str(info.get('age')))if info.get('age') != None else None
152 # print("地址" + info.get('native')) if info.get('native') != None else None
153 #
154 # # aa('張三',age=19,sex='男',native='南京')
155 # mp={"age":19,'sex':'男','native':'南京'}
156 # aa("張三",**mp)
157
158 # def sum(*ps):
159 # s=0
160 # for p in ps:
161 # s=s+p
162 # if(s<100):
163 # return s
164 # ret=sum(1,3,5,6,7,8,8,3)
165 # print(ret)
166 # def fact(n):
167 # for i in (len()<1000):
168 # if n==1:
169 # return 1
170 # if n==2:
171 # return 1
172 # return n+fact(n+1)
173 # fact(1000)
174
175
176
177
178 # --------
179 # def add(i ,j):
180 # i=i+1;j=j-1
181 # return i,j
182 # a,b=add(10,20)
183 # print("%d %d"%(a,b))
184 # print(add(10,20))
185
186 # 斐波拉切數python
187 # 遞歸方式實現 生成前20項
188 # lis =[]
189 # for i in range(20):
190 # if i ==0 or i ==1:#第1,2項 都爲1
191 # lis.append(1)
192 # else:
193 # lis.append(lis[i-2]+lis[i-1])#從第3項開始每項值爲前兩項值之和
194 # print(lis)
195 #
196 # a=0
197 # b=1
198 # while b < 1000:
199 # print(b,end=',')#end 能夠將print輸出到同一行並以 ,號結尾
200 # a, b = b, a+b
201 # lis =[]
202 # def fact(n):
203 # if n ==0 or n ==1:
204 # return 1
205 # return fact(n-2)+fact(n-1)
206 # print(fact(15))
207 # from collections import Iterable
208
209
210 # def fact(lst=[],a=1,b=1):
211 # # print(a,end=" ") if a==1 else None
212 # # print(b,end=" ")
213 # lst.append(b)
214 # if a+b>=1000:
215 # return b
216 # return fact(lst,b,a+b)
217 # lst1=[1,]
218 # fact(lst1)
219 # print(lst1)
220 # 是否可疊帶
221 # s='add'
222 # print(isinstance(s,Iterable))
223 # 計數
224 # s=["a",True,12]
225 # for id,x in enumerate(s):
226 # print("%d %s"%(id,x))
227 # 判斷是否爲函數
228 # print(type(abs))
229 # def f(x):
230 # return x*x
231 # lst=[12,34,54,1]
232 # def map1(fc,c):
233 # ret=[ ]
234 # for unit in c:
235 # ret.append(fc(unit))
236 # return ret
237 # print(map1(f,lst))
238
239 # ap={('a','b'):2,('a','c'):3,}
240 # lst=["%s到%s的距離:%d"%(u[0],u[1],ap.get(u)) for u in ap]
241 # list(map(print,lst))
242
243
244
245
246 # map
247 # from functools import reduce
248 #
249 # scoress=[("張三",78,85,8,),("張三1",78,85,8,3,243),("張三2",78,85,8,24)]
250 # def getMax(a,b):
251 #
252 # return a+b
253 # def proces(u):
254 # return "姓名%s,平均分%d,最高分%d,總分%d"%(u[0],reduce(getMax,u[1:])/(len(u)-1),max(u[1:]),reduce(getMax,u[1:]))
255 # lst=list(map(proces,scoress))
256 # print(lst)
257
258
259 # 最大兩兩相比
260 # from functools import reduce
261 #
262 #
263 # def getMax(a,b):
264 # return a if a>b else b
265 # x=[12,43,45,43,5435,]
266 # print(reduce(getMax,x))
267 from functools import reduce
268
269 lst=[2,34,6,8,98,9,9,8,567,]
270 def reach(mk):
271 return mk>=60
272 def getMin(a,b):
273 return a if a<b else b
274 # filter 過濾,
275 ret=reduce(getMin,list(filter(reach,lst)))
276 print(ret)