發表文章

目前顯示的是 3月, 2024的文章

王致美python內建built-in函數function迴圈loop範圍range

圖片
程式碼 print("練習函數bin, hex, integer") print("4轉二進位",bin(4)) print("7轉二進位",bin(7)) print(4+2+1) print("20轉成16進位",hex(20)) print("FF轉成10進位",int("FF",16)) print("練習函數abs, all, any, ascii") for i in range(-2,3): x = abs(i) print(abs(x)) print("all邏輯,是否全部是真?") x, y, z = 1==1, 2>1, 3>2 #=給值,==判斷 print(all([x,y,z])) print("2>1,-1==1,-2>3有正確的嗎",any([2>1, -1==1, -2>3])) print("2>1,-1==1,-2>3全正確嗎",all([2>1, -1==1, -2>3])) #pthon註解range(開始,結束) print("列印,迴圈for, range範圍") for i in range(33301, 33344): print("字碼character", i,"是",chr(i)) for i in range(65, 70): print(chr(i)) w3schools內建函數列表 https://www.w3schools.com/python/python_ref_functions.asp Python has a set of built-in functions. Function Description abs() Returns the absolute value of a number all() Returns True if all items in an iterable object are true any() Returns ...