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: 如何用 pandas.DataFrame.groupby 做樞紐分析? DataFrame.groupby (by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, observed=False, dropna=True) ; 如何將資料夾中的多個csv檔求平均?Word新增標籤,信封Python機器學習: train_test_split() 切割資料(波士頓地區房價)為訓練資料跟測試資料; from sklearn.model_selection import train_test_split ; xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.3, random_state=42, shuffle=True)Python DOCX 手術刀:精準切片與瘦身 (OOXML 實戰); from lxml import etree; doc_xml = zfin.read('word/document.xml') ; doc_tree = etree.fromstring(doc_xml) ; used_rids = set( doc_tree.xpath( "//@r:embed | //@r:link | //@r:id", namespaces=ns_map)) #獲取 word/document.xml 有使用的used_rids => 讀取 document.xml.rels 建立白名單 keep_files以及黑名單 rels_to_remove ,要移除的Relationship節點 => 從 XML 樹中移除未使用的 Relationship 節點 => 重寫 Zip (過濾孤兒檔案, 更新document.xml.rels,其他原樣複製)Python TQC考題408 奇偶數個數計算Python: 如何使用 pandas.DataFrame.plot 繪圖? ax=df.plot( subplots=False ) ; plt.subplots_adjust( hspace=1 ) 調整子圖間的間距Python: 如何用tkinter做出 對話 Button GUI? 點Button即可選擇檔案 ; fpath = filedialog .askopenfilename() ; self.process_button.pack(fill='both', expand=True) ; 物件導向避免使用全域變數Python: 如何向上取整到最接近的2的幾次方? range_bins = int(math.pow(2, math.ceil( math.log2(num_adc_samples) )))Word:追蹤修訂,將子文件插入/併入主控文件,分割長文件
0 Python:如何確保只有單欄資料的變數,其型態是 pandas.Series 而非單欄的DataFrame? pandas.DataFrame.squeeze() ; df.set_index() 將兩欄的df,其中一欄設為index後,其型態是單欄的DataFrame還是Series? 2023-05-01
0 Python: 對純量(整數int,浮點數float)取list()跟array()會如何? numpy.array(scalar) ; list(scalar), 2D array的運算 2022-11-06
0 Python: 如何批量將檔案更名?os.rename(old_name, new_name) ; glob.glob() #讀取資料夾中的所有檔案 ; os.path.split(fpath) = os.path.dirname(fpath) , os.path.basename(fpath) ; os.path.splitext(basename) #分離主/副檔名 2023-10-04
近期留言