Python TQC考題504 次方計算,def compute(x,y):return x**y by 儲蓄保險王 · 2022-04-29 def compute(x,y): return x**y x=eval(input()) y=eval(input()) ans=compute(x,y) print(ans) “”” 簡單到無需自定義函數 只是練習如何自定義函數 14, 3是使用者input() 不要直接寫進去 compute(14,3) “”” 相關文章Python: 如何用isin()函式切片出兩個 pandas.Series 重複的元素? ser_bool = 長的Series.isin (短的Series); numpy.bool_ ; WR75 WR42 WR28頻段為何?Python: 格式化字串 .format() 順序order,關鍵字keyword,索引index .2% 換算為百分比,精準到小數點下兩位Python: 十進位的67305985是二,八,十六進位的多少?二進位前綴0b ; 八進位octal (前綴0o) ; 十六進位hexadecimal(前綴0x) ;前綴可將二,八,十六進位數字轉為十進位 ; 十進位數字轉為二,八,十六進位: bin(number) ; oct(number) ; hex(number)Python: openCV無法使用中文路徑的話,該如何處理?bgrImage = cv2.imdecode (numpyarray, cv2.IMREAD_GRAYSCALE)Python物件導向(Object-oriented programming,簡稱OOP),類別(Class), 物件(Object), 屬性(Attribute)=變數, 方法(Method)=函式, 建構式(Constructor) def __init__(self,x,y): 計算計程車車資, assert 斷言, 全域變數與區域變數Python: list的加法跟乘法(減法跟除法不行), list(n)*m #有m個元素n, ndarray.tolist()可以將array轉為listPython: Visual Studio Code (VS code) 程式碼input(),終端機卻無法輸入資料且顯示亂碼,該如何設定?齒輪 > 設定,搜尋: run in terminal, 打勾: Wether to run code in integrated Terminal.Python: pandas, import pandas as pd ; s =pd.Series() ; s.index ; s.values; 類比於dict.keys ; dict.values ; Series有index跟value,可以跟dict互轉;同list的切片可以取值Python: pandas.DataFrame與numpy.ndarray回測1972年初~2022年底,小型/價值股溢酬是否存在?
0 Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’ 2023-05-11
近期留言