16/4/2024

Run Settings
LanguagePython
Language Version
Run Command
# falsy conditional value = (False or [] or None or ''or () \ or {} or 0 ) """whats is the last value?""" print(value) value = (1 and [1]and (1,2) and 1.0 and [1,2]) print(value) a=5 value = (a ==5 and a <10) """ a.__lt__(10) 等於a <10) a.__gt__(10) """ print(value) default_city ="kw" city='hk' city = city or print("please input city") \ or default_city print(city) city='' city = bool(city) or print("please input city") \ or default_city print(city) #https://pythongeeks.org/python-operator-precedence/ #LIST 折開兩件 print("LIST 折開兩件") a = [1,2,3,4,5,6] b = a[0] c = a[1::] d,*e,f=a str_list =[str(numABC) for numABC in a] g=[*str_list] print(d) print(e) #the rest elements group into as list print(f) print(g) #合并成一个新列表 print("合并成一个新列表") l1 =[1,2,3] l2 =[4,5,6] l=[*l1,*l2] print(l) l1 =[1,2,3] l2 ='x,y,z' l=[*l1,*l2] print(l) print("mark six 1-49") six= {i for i in range(1,50)} print(six) #如果用SET 會RANDON 因為不會排 print("如果用SET 會RANDON 因為不會排") s={10,-99,3,'d'} print(s) s={10,-99,3,'d'} a, *b, c =s print(a) print(b) print(c) print("*應用") d1= {'p':1,'y':2} d2= {'t':3,'h':4} d3= {'h':5,'o':6,'n':7} l = [*d1,*d2,*d3] s = {*d1,*d2,*d3} print(l) print(s) print("**應用") d1= {'p':1,'y':2} d2= {'t':3,'h':4} d3= {'h':5,'o':6,'n':7} ee={**d1,**d2,**d3} print(ee) dd={"p":1,"y":2,"t":3,"h":4} a,*b=dd print("dd") print(dd) di ={"name":"john","age":30} ali =[*di] li =[value for key,value in di.items()] ii =[key for key,value in di.items()] lli = di.values() print("lli",lli) print(ali) print(ii) print(li) print("function 無處不在") def a(): print("i am from function a") b={"name":"john","age":a} b["age"]() print("function 內套function 無處不在2") print("###lambdaba 用途###") x = lambda a: a + 10 print(x(5)) print("###lambdaba 用途###") def a(): print("i am from function a") def d(e): e() b={"name":"john","age":lambda : print("i am from BBB")} b["age"]() c={"addres":"main street","age":b["age"]} c["age"]() d(a) d(c["age"])
Editor Settings
Theme
Key bindings
Full width
Lines