劉任昌python輸入import數學math函式庫define定義function函數

from math import * #劉任昌從math輸入所有函式
# import math #劉任昌輸入math函式庫
def abc(r): #定義函數abc
  print("圓面積:  "+str(pi*r*r))
  print("圓周長:  "+str(pi*r*2))
  print("球體積:  "+str(pi*r*r*r*4/3))
  print("球表面積:"+str(pi*r*r*4))
def tri(z):
  print("正弦sin "+str(sin(z)))
  print("餘弦cos "+str(cos(z)))
def group(r, t):
  abc(r)
  tri(t)
r , t = 1, pi/3   #半徑, 60度=pi/3
group(r,t)

import math

from math import *

心得使用ul=undered list標記語言

  • 輸入函式庫,例如比較
    • import math
    • from math import all
  • 自訂函數
    • def 函數名稱()
    • Define
    • Definite當然的
    • Definition
    • 常常被利用於模組化程式碼

貼到VS Code建立視窗

from math import *   #劉任昌從math輸入所有函式
from tkinter import *#從建構視窗函式庫輸入所有函式
# import math #劉任昌輸入math函式庫
def abc(r): #定義函數abc
  print("圓面積:  "+str(pi*r*r))
  print("圓周長:  "+str(pi*r*2))
  print("球體積:  "+str(pi*r*r*r*4/3))
  print("球表面積:"+str(pi*r*r*4))
def tri(z):
  print("正弦sin "+str(sin(z)))
  print("餘弦cos "+str(cos(z)))
def group(r, t):
  abc(r)
  tri(t)
r , t = 1, pi/3   #半徑, 60度=pi/3
group(r,t)
tk = Tk()
tk.title("劉任昌tkinter視窗")
canvas = Canvas(tk, width=600, height=400)
canvas.pack()
label1 = Label(tk, text="輸入半徑:", font=('微軟粗黑體', 20))
label1.pack()
tk.mainloop()

留言

  1. https://d10917257.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. https://d11150113.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  4. https://cpc920508123.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  5. https://jasperyang.blogspot.com/2023/05/blog-post.html

    回覆刪除
  6. https://hhhaann.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  7. https://enchenghu0905.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  8. 作者已經移除這則留言。

    回覆刪除
  9. https://www.blogger.com/blog/post/edit/preview/4399220548584548192/6071718889808964017

    回覆刪除
  10. https://d11150108.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  11. https://d11150114.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  12. https://jjjjjyyy.blogspot.com/2023/05/pythonimportmathcdefinefunction.html

    回覆刪除
  13. https://cindy-javascript.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  14. https://spencer0309.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  15. https://jdoifjopq1264.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  16. https://trequiem.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  17. https://lihtml-css-javascript-java.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  18. https://chenyouzheng0329.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  19. https://iuytjhg5261.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  20. https://d11150115.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  21. https://alien1213.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  22. https://pandora-mo.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  23. https://rtytrdtfg.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除
  24. https://fongcyf.blogspot.com/2023/05/pythonimportmathdefinefunction.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌對照Python與JavaScript指令

劉任昌Python集合set清單list元組tuple字典dictionary

劉任昌python, input, str, float