劉任昌python內建built-in函數functions迴圈loop

上面style指令要在html模式貼在最上面
<style>h1{text-align:center; background-color:blue; color: white;  border: solid medium blue; padding 10px;border: 10px green; border-radius:10px; padding:10px;}
  </style> 

截圖

程式碼

print(int(10))
print(int("ff",16))
print(int('100',16))
print(int('100',8))
a = [0>1, 2>1, 3==3]#串列list使用square bracket中括號
print("是否all全真",all(a))
print("存在任何any一個真",any(a))
print("劉任昌bin二進位輸出一到9")
for i in range(10): #0 to 9進位1
   print(bin(i))
for i in range(0, 200, 10):
   print(hex(i))
a = ('蘋果', '香蕉', '櫻桃',"durian")
b = "Hello World"
c = 33
d ={'蘋果', '香蕉', '櫻桃',"durian"}
e=['蘋果', '香蕉', '櫻桃',"durian"]
print("a元組typle", type(a))
print("b字串", type(b))
print("c整數integer", type(c))
print(type(d), type(e))

w3schools內建函數列表

Python has a set of built-in functions.
FunctionDescription
abs()Returns the absolute value of a number
all()Returns True if all items in an iterable object are true
any()Returns True if any item in an iterable object is true
ascii()Returns a readable version of an object. Replaces none-ascii characters with escape character
bin()Returns the binary version of a number
bool()Returns the boolean value of the specified object
bytearray()Returns an array of bytes
bytes()Returns a bytes object
callable()Returns True if the specified object is callable, otherwise False
chr()Returns a character from the specified Unicode code.
classmethod()Converts a method into a class method
compile()Returns the specified source as an object, ready to be executed
complex()Returns a complex number
delattr()Deletes the specified attribute (property or method) from the specified object
dict()Returns a dictionary (Array)
dir()Returns a list of the specified object's properties and methods
divmod()Returns the quotient and the remainder when argument1 is divided by argument2
enumerate()Takes a collection (e.g. a tuple) and returns it as an enumerate object
eval()Evaluates and executes an expression
exec()Executes the specified code (or object)
filter()Use a filter function to exclude items in an iterable object
float()Returns a floating point number
format()Formats a specified value
frozenset()Returns a frozenset object
getattr()Returns the value of the specified attribute (property or method)
globals()Returns the current global symbol table as a dictionary
hasattr()Returns True if the specified object has the specified attribute (property/method)
hash()Returns the hash value of a specified object
help()Executes the built-in help system
hex()Converts a number into a hexadecimal value
id()Returns the id of an object
input()Allowing user input
int()Returns an integer number
isinstance()Returns True if a specified object is an instance of a specified object
issubclass()Returns True if a specified class is a subclass of a specified object
iter()Returns an iterator object
len()Returns the length of an object
list()Returns a list
locals()Returns an updated dictionary of the current local symbol table
map()Returns the specified iterator with the specified function applied to each item
max()Returns the largest item in an iterable
memoryview()Returns a memory view object
min()Returns the smallest item in an iterable
next()Returns the next item in an iterable
object()Returns a new object
oct()Converts a number into an octal
open()Opens a file and returns a file object
ord()Convert an integer representing the Unicode of the specified character
pow()Returns the value of x to the power of y
print()Prints to the standard output device
property()Gets, sets, deletes a property
range()Returns a sequence of numbers, starting from 0 and increments by 1 (by default)
repr()Returns a readable version of an object
reversed()Returns a reversed iterator
round()Rounds a numbers
set()Returns a new set object
setattr()Sets an attribute (property/method) of an object
slice()Returns a slice object
sorted()Returns a sorted list
staticmethod()Converts a method into a static method
str()Returns a string object
sum()Sums the items of an iterator
super()Returns an object that represents the parent class
tuple()Returns a tuple
type()Returns the type of an object
vars()Returns the __dict__ property of an object
zip()Returns an iterator, from two or more iterators

補充與心得

  • int(a,b)將b進位的a轉成10進位
  • bin(a)將10進位a轉成2進位
  • hex(a)將10進位a轉成16進位
  • type(a)呈現a的型態:set集合、list串列、元組tuple、字典dictionary、整數integer、字串string

留言

  1. https://wuhongbing.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  2. https://naiyuanzhang1226.blogspot.com/2024/03/pythonbuilt-in-functionsstringmethodslo.html

    回覆刪除
  3. https://chan-wan-yi.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  4. https://stanley-ouo.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  5. https://zhen-zhen4869.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  6. https://kuoyiting.blogspot.com/2024/03/python-built-in-function.html

    回覆刪除
  7. https://linziwei0308.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  8. https://wujiaqi1010.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  9. https://sandy06252023.blogspot.com/2024/03/pythonbuilt-infunctionsstringmethodsloop.html

    回覆刪除
  10. https://shenzhenxuan.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  11. https://jhuang-huei.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  12. https://kitty030994.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  13. https://zzl1102.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  14. https://li1007.blogspot.com/2024/03/pythonbuilt-infunctionslooprange.html

    回覆刪除
  15. https://www.blogger.com/blog/post/edit/preview/246862186134119617/6040666271100516052

    回覆刪除
  16. https://yiingxxn.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  17. https://wang-yu-jia-wangyujia.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html


    回覆刪除
  18. https://liu-guang-wei.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  19. https://su-you-an.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  20. https://hank20050328.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  21. https://wnagenqiiiiiiiiiiii.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  22. https://linchinppei.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  23. https://chen0119.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  24. https://wenhuichenchen.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  25. https://xu0625.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除
  26. https://caipeishan1223.blogspot.com/2024/03/python-built-in-function-loop_12.html

    回覆刪除
  27. https://0209tongting.blogspot.com/2024/03/pythonbuilt-infunctionlooprange.html

    回覆刪除
  28. https://willie-lai611.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  29. https://giinasmile.blogspot.com/2024/03/pythonbuilt-infunctionsloop.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

2025年3月4日上課Python 陣列array串列的函數(方法)

劉任昌Javascript物件導向Python物件導向